Create a table with a primary key that automatically increments with a default value that is not an empty comment by sql

Source: Internet
Author: User

--CREATE database Db_std_mgr_sys; UseDb_std_mgr_sys;Create TableStudent (std_idbigint  not NULLAuto_increment,std_namevarchar(Ten) not NULL default "', Std_codevarchar( -) not NULL default "'Comment'study number, the value is unique', Std_sexvarchar(8) not NULL default "', Std_phonevarchar( -) not NULL default "', school_idbigint  not NULL default -1Comment'Your School ID', grade_idBIGINT  not NULL default -1Comment'your Grade ID', cls_idbigint  not NULL default -1Comment'Your class ID',Primary Key(std_id)) engine=Innodb,charset='UTF8', comment='Student Table';

Table II:

 UseDb_std_mgr_sys;Create Table`User' (UIDbigint  not NULLAuto_increment,usernamevarchar( -) not NULL, ' password 'varchar( +) not NULL, Phonevarchar( -) not NULL, emailvarchar( -) not NULL,Primary Key(UID),Unique Key(username),Unique Key(phone),Unique Key(email)) Engine=INNODB CharSet=Utf8
/* Note that there must be () behind the key and not directly the primary key UID, where the key is the index meaning,
And the front of the primary, unique is a modification, the primary key is also a kind of index, if only key is not decorated means that the index is a normal index;
If unique key uq_username (username), then the index is named Uq_username, otherwise the index name and the index column name is the same as username*/

Create a table with a primary key that automatically increments with a default value that is not an empty comment by sql

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.