MariaDB SQL Insert Data

Source: Internet
Author: User

Insert a separate full line, insert a separate section line
INSERT  intocustormersVALUES(NULL,    'Pep E. Lapew',    'Main Street',    'Los Angeles',    'CA',    '90046',    'USA',    NULL,    NULL);

...... The above SQL statement relies heavily on the order in which the columns are defined in the table. It also relies on the order in which information is inserted. Even if you can, there is no guarantee that the next time the table is refactored, the columns remain in exactly the same order. ......

INSERT  intoCustomers (Cust_name, cust_address, cust_city, Cust_state, Cust_zip, Cust_country, Cust_contact, Cust_email)VALUES('Pep E. Lapew',    'Main Street',    'Los Angeles',    'CA',    '90046',    'USA',    NULL,    NULL);
    • Because column names are provided, values must match the column names in the order specified, rather than in the order in which the columns appear in the Performance table. The advantage of this is that, even if the table structure changes, the INSERT statement will still work correctly.

...... Regardless of the INSERT statement you are using,the number of values must be correct . ...... With this syntax, columns can be ignored. This means that only some columns are provided with values, while the other columns do not. (cust_id is ignored when column names are displayed)

    • Ignore column : The Ignore column must meet one of the following criteria: The column is defined as a null value (no value); A default value is defined by the table. (meaning that if you do not specify a value for the column, it is the default value)

The SQL statement that creates the table is posted here:

CREATE TABLE' Apppowerinfo ' (' ID ')int(Ten) unsigned not NULLAuto_increment COMMENT'self-growing ID', ' Createtime 'int(Ten) unsigned not NULL DEFAULT '0'COMMENT'when the record was created', ' UpdateTime 'int(Ten) unsigned not NULL DEFAULT '0'COMMENT'time of latest update record', ' EndTime 'int(Ten) unsigned not NULL DEFAULT '0'COMMENT'Expiry Time', ' validity 'tinyint(4) unsigned not NULL DEFAULT '1'COMMENT'Validity: 0: invalid; 1: valid;', ' remark 'varchar( -) not NULL DEFAULT "'COMMENT'Notes',  PRIMARY KEY(' id ')) ENGINE=InnoDB auto_increment=2 DEFAULTCHARSET=UTF8;

Note which:

 not NULL DEFAULT ' 0 '

Low_priority

If data retrieval is more important (and often so), you can reduce the priority of the INSERT statement by MARIADB:

INSERT  into

Topics to be continued in this section
    1. Inserting multiple lines
    2. Inserting the retrieved data

MariaDB SQL Insert Data

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.