如何給Sqlite添加復合主鍵


如果是想兩個字段組成一個復合主鍵的話可以如下。
SQL code

sqlite> create table t2 ( ...> id1 int , ...> id2 int, ...> col varchar( 20), ...> constraint pk_t2 primary key (id1,id2) ...> ); sqlite>
 
如果是雙主鍵如下:
[html] view plain copy
 
  1. sqlite> create table t1 (  
  2.    ...>         id      int primary key,  
  3.    ...>         col     varchar(20)  
  4.    ...> );  
  5. sqlite> create unique index uk_t1 on t1 (col);  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM