Basic additions, deletions, changes, queries and table structure of the database
Basic additions, deletions, modifications and queries of the database
1. Add-add / insert data insert into
Which table to insert, those columns, what values?
Statement: insert into table name (column 1, column 2, column 3) values (value 1, value 2, value 3)
Can not be inserted according to the order of the original column, you can also insert some columns, but the value and the column should be one-to-one corresponding, can not be confused!
Insert multiple rows of data at once:
Insert into table name (column 1, column 2) values (value 1, value 2), (value 1, value 2)
2. Change-update data update
Which table, which columns, which values to update
Statement: update table name set column 1 = value 1, column 2 = value 2, column 3 = value 3 where condition
3. Query-query data select
Query all columns of the table: Select * from table name
Query partial column: select column 1, column 2 from table name where condition
4. Delete-Delete data delete
Delete from table name where condition
Modify table structure (alter modify)
1. Modify the table name
Rename table original table name to new table name
Alter table original table name rename to new table name
2. Add columns
Definition of Alter table table name add column name column
3. Modify the definition / properties of the column
New definition of Alter table table name modify column name
4. Modify the order of the columns
Alter table table name modify column 1 definition 1 after column 2
5. Modify the column name
Alter table table name change old column name new column name new definition
6. Delete columns
Alter table table name drop column column name