Add, delete, modify and check the basic operation of mysql
Query
Query all columns
Select * from table name
Example:
Select * from classes
Query the specified column
You can use as to specify aliases for columns or tables
Select column 1, column 2. From table name
Example:
Select id,name from classes
Increase
Note: the primary key column grows automatically, but it needs to occupy a space when inserting all the columns, usually using 0, and the actual data shall prevail after successful insertion.
Full column insertion: the order of values corresponds to the order of fields in the table
Insert into table name values (...)
Example:
Insert into students values (0Jing Guo Jing, 1pm Mongolia, 2016-1-2')
Partial column insertion: the order of values corresponds to the column order given
The name of the insert into table (column 1.) Values (worth 1pm...)
Example:
Insert into students (name,hometown,birthday) values ('Huang Rong', 'Peach Blossom Island', '2016-3-2')
The above statement can insert one row of data into a table at a time, or multiple rows of data at a time, thus reducing communication with the database.
Full column multiple row insert: the order of values corresponds to the column order given
The insert into table name is values (...), (...).
Example:
Insert into classes values (0gramme python 1'), (0recorder python 2')
The name of the insert into table (column 1.) Values (worth 1pm), (worth 1pm...)
Example:
Insert into students (name) values ('Yang Kang'), ('Yang Guo'), ('Xiao Longnu')
Modify
Update table name set column 1 = value 1, column 2 = value 2. Where condition
Example:
Update students gender=0,hometown=' Tomb 'where id=5
Delete
Delete from table name where condition
Example:
Delete from students where id=5
Logical deletion is essentially a modification operation.
Update students set isdelete=1 where id=1