Third, MySQL build table template

Source: Internet
Author: User

1. Create a table template

SET foreign_key_checks=0;
DROP TABLE IF EXISTS ' g_test ';
CREATE TABLE ' G_test ' (
' id ' int (one) unsigned not NULL auto_increment COMMENT ' id ',
' Update_time ' timestamp NULL DEFAULT current_timestamp COMMENT ' Update Time ',
' Begin_time ' timestamp null DEFAULT null COMMENT ' expiration (start) ',
' End_time ' timestamp null DEFAULT null COMMENT ' validity period (end) ',
' title ' varchar ($) DEFAULT NULL COMMENT ' product title ',
' Products_scale ' decimal (11,2) DEFAULT ' 0.00 ' COMMENT ' fundraising scale ',
' Min_profit ' decimal (11,5) DEFAULT ' 0.00000 ' COMMENT ' annual income ',
PRIMARY KEY (' id ')
) Engine=innodb auto_increment=1 DEFAULT charset=utf8 comment= ' Test form ';

Note: (1) auto_increment=n indicates that the starting position of the self-growth is n
(2) Cancel foreign KEY constraint: SET foreign_key_checks=0; In MySQL, you cannot delete a table and modify the table structure if a FOREIGN key constraint is established between the table and the table.
Workaround: Cancel the foreign key constraint in MySQL: set foreign_key_checks=0; then export the data from the original table to the SQL statement, recreate the table, and then import the data using SQL.
Then set the FOREIGN KEY constraint: set Foreign_key_checks=1;

Third, MySQL build table template

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.