MySQL如何创建主键?Alter table add PRIMARY KEY的用法和例子

来源:互联网 发布:港股查询软件 编辑:程序博客网 时间:2024/05/16 16:37
[java] view plaincopy
  1. -- 创建一个无主键的表格  
  2. create table testNoPK (  
  3.   id int not null,  
  4.   name varchar(10)  
  5.  );  
  6.    
  7. -- 创建索引  
  8.  alter table testNoPk   
  9.    add primary key PK_testNoPK (id);  
原创粉丝点击