Table operation Syntax Differences
When building a table, only the self-increment syntax is different.
The primary key (PRIMARY key), the foreign key (FOREIGN key), non-null (NOT NULL), unique (unique), and default (defaults) are the same, and the self-increment implementation is different.
The following is a list of the 3 common database-building and initialization test statements:
CREATE TABLECountry (Idint PRIMARY KEY, Namevarchar( -));CREATE TABLEPerson (Idint PRIMARY KEY, Countryidint, Namevarchar( -) not NULL UNIQUE, Sexint DEFAULT 0, CONSTRAINTFk_cid_pidFOREIGN KEY(Countryid)REFERENCESCountry (Id));
Insert test data:
INSERT intoCountryVALUES(1,'Shu');INSERT intoCountryVALUES(2,'Wei');INSERT intoCountryVALUES(3,'Wu');INSERT intoPersonVALUES(1,1,'Liu Bei',1);INSERT intoPersonVALUES(2,1,'Guan Yu',1);INSERT intoPersonVALUES(3,1,'Zhang Fei',1);INSERT intoPersonVALUES(4,2,'Caocao',1);INSERT intoPersonVALUES(5,2,'Guo Jia',1);INSERT intoPersonVALUES(6,2,'Code Wei',1);INSERT intoPersonVALUES(7,3,'Sun Quan',1);INSERT intoPersonVALUES(8,3,'Zhou Yu',1);INSERT intoPersonVALUES(9,3,'Big Joe',2);
|
Sql server |
Mysql |
Oracle |
Self-increment |
Identity (+) |
Auto_increment |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL Server, MySQL, Oracle syntax differences Small collection