SQL Server, MySQL, Oracle syntax differences Small collection

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.