Data insertion in MySQL takes only two major steps.

Source: Internet
Author: User

The following articles mainly describe the actual operation steps of MySQL Data insertion. We often encounter the project of MySQL Data insertion in actual operations, if you want to learn more about the actual operations, you can use the following articles.

Step 1

Using the INSERT statement to INSERT a record is a record for each row in the database table. inserting a record is actually inserting a row into the table)

Format:

 
 
  1. Insert into table_name data table name) VALUES (value 1, value 2, value 3 ...);

The VALUES and character segments in the parentheses following the VALUES keyword must be consistent with the field data type defined in the table you created!

 
 
  1. MySQL (best combination with PHP)> insert into emp values
  2. -> ('20140901', 'xiaotian ', 100005, '2017-07-10', 'male ');

After successful insertion, the following information is displayed:

 
 
  1. Query OK, 1 row affected (0.03 sec) 

Step 2

Check the data in the table to check whether the data has been successfully inserted)

 
 
  1. MySQL (the best combination with PHP)> select * from emp;

After successful insertion, the data is displayed as follows:

 
 
  1. + -------- + ---------- + --------- + ------------ + --------- +
  2. | Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |
  3. + -------- + ---------- + --------- + ------------ + --------- +
  4. | 100005 | Xiaotian | 27 | 3000 | 1979-07-10 | male |
  5. + -------- + ---------- + --------- + ------------ + --------- +
  6. 1 row in set (0.00 sec)

Format of one-time insertion of multiple rows: insert into table_name data table name) VALUES (value 1, value 2, value 3 ...), (value 1, value 2, value 3 ...);

 
 
  1. MySQL (best combination with PHP)> insert into emp values
  2. -> ('20140901', 'hongfeng', 100001, '2017-01-01 ', 'male '),
  3. -> ('20140901', 'lilay', 100002, '2017-12-31 ', 'fmale ');

You can view the inserted data results:

 
 
  1. + -------- + ---------- + --------- + ------------ + --------- +
  2. | Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |
  3. + -------- + ---------- + --------- + ------------ + --------- +
  4. | 100005 | Xiaotian | 27 | 3000 | 1979-07-10 | male |
  5. | 100004 | Hongfeng | 29 | 8000 | male |
  6. | 100002 | Lili | 27 | 7000 | 1979-12-31 | fmale |
  7. + -------- + ---------- + --------- + ------------ + --------- +
  8. 3 rows in set (0.00 sec)

The above content is an introduction to MySQL data insertion. I hope you will find some gains.

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.