Insert table record (1):
Demo: This method supports arithmetic when writing a value
1 # Create a database and use a database2 CREATE DATABASEGzcsql;3 UseGzcsql;4 # Create a data table5 CREATE TABLEtable1 (6IdSMALLINTUNSIGNEDPRIMARY KEYAuto_increment,7NameVARCHAR( -) not NULL,8PasswordVARCHAR( +) not NULL,9AgeTINYINTUNSIGNED not NULL DEFAULT Ten,Ten Sex BOOLEAN One ); A # Insert a record, if it is not indicated which columns to insert, you need to insert all, the primary key can use default or null to let it use the defaults, the default values are marked defaults can also use the default value - INSERTTable1VALUES(NULL,'Tom','123',DEFAULT,1);
View Code
Insert more than one record at a time, separated by commas between multiple records:
1 insert table1 values (null , " xiaoming , ' 456 , 21 , Span style= "color: #800000; Font-weight:bold; " >1 ), values (default , ' xiaoguo ' , 666 ' ,
View Code
Insert Table record (2):
Demo: The difference between this method and the first method is that this method can use subqueries, and only one record can be inserted at a time
MySQL 5. Manipulating the data in the table