MYSQL Learning Series --DML statement (a)

introduction:

Data manipulation language (Data Manipulation Language, DML) is the SQL language, is responsible for operating data access instruction set to work on database objects to INSERT, UPDATE, DELETE three kinds of instruction as the core, representing the insert, update and delete, are developed to data-centric applications will certainly use to instructions.

Hands-on

Before the operation, some database creation, table creation, not here in detail to say, do not know how you can look at my previous article written MYSQL Learning Series --DDL statement
query uses select * from 表名;the premise that access to the database
MYSQL Learning Series --DML statement (a)
I am here because what data did not insert, so the query is empty, then we insert at the data bar
1) insert record
1> insert record
syntax: insert into 表名(字段1,字段2,字段3,...,字段n) values(值1,值2,值3,...,值n);
use desc 表名to see what fields
can not specify the field name, but the order of the latter values should be consistent with the sort field, field they have a consistent number
MYSQL Learning Series --DML statement (a)
2> one inserts a plurality of data

     insert into 表名(字段1,字段2,字段3,...,字段n)
                 values
                 (值1,值2,值3,...,值n),
                 (值1,值2,值3,...,值n),
                 (值1,值2,值3,...,值n);

MYSQL Learning Series --DML statement (a)
2) update records
1> update a table
update 表名 set 字段1=值1,字段2=值2,...字段n=值n [where 条件];
we will name field number = 3 (name) into abc
MYSQL Learning Series --DML statement (a)
2> Update the plurality of data tables
we could create a new table, the table name to student1
MYSQL Learning Series --DML statement (a)
We then change studet the abc to hhh, table student1 of xiaolan into ywboy
MYSQL Learning Series --DML statement (a)
3) delete records
1> delete data in a single table
delete from 表名 [where 条件];
we attempt to delete the student's name hhh table that personal
MYSQL Learning Series --DML statement (a)
data 2> delete multiple tables
delete 表1,表2,...表n from 表1,表2,...表n [where 条件];
either a single table or multi-table, where conditions will not add to delete all records in the table, so be careful when operating.
This you on their own to try it ~

Guess you like

Origin blog.51cto.com/14113984/2428917