Data table increment operation in MySQL

Source: Internet
Author: User
Tags ming

today to learn to add to the table, write a blog summary, PS: All of the following comments are all my computer on the completion of the operation, and then copied to the Notepad added. As for the implementation of the time can be added to the comments, it remains to be verified. Select Library
Mysql> show databases, #查看目前有哪些数据库存在 +--------------------+| Database           |+--------------------+| information_schema | | ceshi_ku           | | mysql              | | performance_schema |+------ --------------+4 rows in Set (0.00 sec) mysql> use Ceshi_ku; #选择该数据库, wait for the table to be built, seemingly select a database can not ";" Reading table information for Completion of table and column namesyou can turn off this feature to get a quicker startup With-adatabase changed
Build Table
Mysql> CREATE Table Biao,    ID int,    name char (+),    gender char (2),    go Ngsi char (    gongzi float)    ; #先建立一个简单的表, number, name, gender, company, salary, build table is not the focus now, is convenient next operation query OK, 0 rows Affected (0.13 sec) mysql> select * from Biao; #查看表中的内容, currently empty table Null Set (0.00 sec)
Insert data (all columns, multiple lines)
mysql> INSERT into biao# Select which table you want to insert    , (Id,name,gender,gongsi,gongzi) #往哪些列里面插入内容    , values# and then start inserting 3, Separate with "," and the Last with ";"    --(1, ' Ma Yun ', ' n ', ' Tao Bao ', 6000.5), #把要插入内容依次写好, non-exchangeable order! to correspond    (2, ' Xiao Hong ', ' V ', ' Xin Lang ', 5000.7),-    -(3, ' Xiao Ming ', ' n ', ' Bai du ', 3000.4); Query OK, 3 rows affected (0.08 sec) records:3  duplicates:0  warnings:0mysql> select * from Biao; #查看表中的内容 will now be sent More than 3 lines +------+-----------+--------+----------+--------+| ID   | name      | gender | Gongsi   | gongzi |+------+-----------+--------+----------+--------+|    1 | Ma Yun    | n      | Tao Bao  | 6000.5 | |    2 | Xiao Hong | V      | xin lang | 5000.7 | |    3 | Xiao Ming | n      | bai du   | 3000.4 |+------+-----------+--------+----------+--------+3 rows in Set (0.01 sec)
Insert data (default column, single row)
mysql> INSERT INTO biao# this time not specifying which columns to insert, not specifying is to insert all columns, values----    4, ' Li Si ', ' n ', ' Sou Hu ', 9000.2; This time, you can insert only one row or multiple lines, just use "," to separate the query OK, 1 row affected (0.07 sec) mysql> select * from Biao; #查看表内容, you'll find a line +------+------More than last time. -----+--------+----------+--------+| ID   | name      | gender | Gongsi   | gongzi |+------+-----------+--------+----------+--------+|    1 | Ma Yun    | n      | Tao Bao  | 6000.5 | |    2 | Xiao Hong | V      | xin lang | 5000.7 | |    3 | Xiao Ming |      bai du   | 3000.4 | |    4 | Li Si     | n      | sou hu   | 9000.2 |+------+-----------+--------+----------+--------+4 rows in Set (0.00 sec)
Insert Data (Specify columns, multiple rows)
mysql> Insert into Biao (Id,name,gongsi,gongzi) #这次不是往所有列插入, but part column, values---5, ' Lao Wang ', ' Wang Yi ', 1000.5 ), #依次写好便可, remember Correspondence,--(6, ' Xiao Li ', ' Ku Gou ', 700.1); Query OK, 2 rows affected (0.15 sec) records:2 duplicates:0 warnings:0mysql> select * from Biao; #查看表内容, the last time we found 2 more lines, But "gender" is empty +------+-----------+--------+----------+--------+| ID | name | Gender | Gongsi |    Gongzi |+------+-----------+--------+----------+--------+| 1 | Ma Yun | n | Tao Bao |    6000.5 | | 2 | Xiao Hong | V | Xin Lang |    5000.7 | | 3 | Xiao Ming | n | Bai du |    3000.4 | | 4 | Li Si | n | Sou hu |    9000.2 | | 5 | Lao Wang | NULL | Wang Yi |    1000.5 | | 6 | Xiao Li | NULL |  KU Gou | 700.1 |+------+-----------+--------+----------+--------+6 rows in Set (0.00 sec) 
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.