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