Syntax errors that are easy to ignore in MySQL statements

Source: Internet
Author: User

$ STR = "create table test (
Id int (11) not null auto_increment primary key,
Name varchar (255) not null,
IP varchar (255) not null,
Ly text not null,
Addtime datetime not null default '2017-00-00 00:00:00 ',
) Type = InnoDB ;";

Version: MySQL 5.0
----------------------------------------------

The preceding SQL statement took me three hours to find out where it was wrong.

This gives me a deeper understanding of the syntax of SQL statements.

Summary:

1. in MySQL, uppercase and lowercase letters are not differentiated.

2. Do you have a semicolon at the end.

Type = InnoDB; "; and type = InnoDB"; are correct.

3. Define the last security segment and do not need ",". (that is, this problem has caused me a headache for three hours)

Error: addtime datetime not null default '2017-00-00 00:00:00 ',

Correct: addtime datetime not null default '2017-00-00 00:00:00'

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.