The difference between MySQL and SQLServer in data insertion

Source: Internet
Author: User
Environment: MySQLSever5.1SQLServer2008R2 problem: the difference between MySQL and SQLServer in data insertion is shown in the following figure: MySQL: SQLServer: Create a table in MySQL and auto-increment the primary key. when inserting data, if the column name is not specified (indicating that each field is assigned), the column number does not match. The specified column name is inserted normally.

Environment: MySQL Sever 5.1 SQLServer 2008 R2 problem: the difference between MySQL and SQLServer in data insertion is shown in the following figure: MySQL: SQLServer: Create a table in MySQL and auto-increment the primary key, when you insert data, if you do not specify a column name (indicating that each field is assigned), the column number does not match. If you specify a column name, the data is inserted normally.

Environment: MySQL Sever 5.1 + SQLServer 2008 R2

Problem: The difference between MySQL and SQLServer in data insertion

Let's first look at two figures:

MySQL:


SQLServer:


Create a table in MySQL and the primary key is auto-incrementing. when data is inserted, the column name is not specified (indicating that each field is assigned a value). If the columns do not match, the specified column name is inserted normally; in SQLServer, the table's primary key is also auto-incrementing, but the column name can be inserted normally without being specified.

Appendix SQL:

MySQL


create table tb_user(id int primary key auto_increment,name varchar(20) not null,password varchar(16) not null);

SQLServer


create table tb_user(id int primary key identity,name varchar(20) not null,password varchar(20) not null);


Summary: when you use the command line to insert data, if you assign values to each field, you must specify the column name in MySQL instead of SQLServer. It can be seen that different databases support different SQL statements. Pay attention to these differences and summarize them. I would also like to remind you that using databases should not use graphical interfaces as much as possible. This will make you stupid and will not be helpful in understanding SQL. RecommendedCommand LineOperate the database.




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.