MySQL 5. Manipulating the data in the table

Source: Internet
Author: User

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

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.