Get the App
SLTechnology News&Howtos  ›  Database  › 

Basic additions, deletions, changes, queries and table structure of the database

Shulou Source: shulou.com Published: 2022-06-01 08:48:54 09月19日 Update

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

Tags: Data conditions queries statements order updates databases structure confusion one-to-one correspondence attributes query tables multiple rows Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB MySQL Apple Linux Shulou Technology