First Operation MySQL

Source: Internet
Author: User

where is the error----the MySQL command?

The answer semicolon should be in English environment and not in Chinese;

NOTICES:A: A single quotation mark to be used in a table and a backslash

1. Table creation: Createtabkle table name

(

Type of column name [constraint ],

Type of column name [constraint ],

Type of column name [constraint ],

);

Create a student id,name,age;

CREATE TABLE ' tb_student '

(

' id ' bigint DEFAULT NULL,

' Name ' VARCHAR (DEFAULT NULL),

' Age ' INT (one) DEFAULT NULL

) Engine=innodb DEFAULT Charset=utf8;

2, the constraint of the table:

A, non-null constraint DEFAULT not NULL

B, UNIQUE constraint:unique

Unique the contents of the column in the table must be unique

CREATE TABLE ' tb_student '

(

' id ' bigint DEFAULT NULL,

The ' name ' VARCHAR ( UNIQUE) is not NULL,

' Age ' INT (one) DEFAULT NULL

) Engine=innodb DEFAULT Charset=utf8;

Constraints on the C primary key :

1PRIMARY KEY is non-null and unique

2auto_increment. starting from 1. Step is 1,

The design of a primary key that uniquely identifies a row of data

1: Single Field primary key:

Composite PRIMARY Key

2 primary keys are divided into two types

1, Natural primary key

2, Proxy primary key

CREATE TABLE ' tb_student '

(

' id ' bigint DEFAULT NULL,

The ' name ' VARCHAR (UNIQUE) is not NULL,

' Age ' INT (one) DEFAULT NULL,

Primery KEY (' id ')

) Engine=innodb DEFAULT Charset=utf8;

Constraints on foreign keys

First Operation MySQL

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.