About the collation of common commands in MySQL database:
One: For the operation of the database
show databases; Displays all database names under the current user
Use database_name; Enter the current database
CREATE DATABASE database_name;
DROP DATABASE database_name;
Second: The operation of the table
DDL operations: Data Definition language
CREATE TABLE table_name (
ID int primary KEY auto_increment,
Name varchar (20),
); Build a Table statement
DROP TABLE TABLE_NAME, delete the statement of the tables, delete the contents of the table and the table structure directly.
TRUNCATE TABLE table_name; Deletes the contents of the tables, preserves the structure of the table, and does not roll back, the efficiency is high.
Delete from Talbe_name, deleting the contents of the table, without deleting the table's mechanism, is less efficient than truncate.
Rename table Old_name to new_name; Modify the name of the tables.
ALTER TABLE table_name ADD COLUMN_NAME varchar (30);
ALTER TABLE table_name DROP COLUMN_NAME varchar (30);
ALTER TABLE table_name MODIFY COLUNM_NAME varchar (30);
DESC table_name; Query table structure
DML: Data Manipulation language
Delete from table_name where column_table=column_value; Delete data under condition
UPDATE table_name Set column_name= ", column=" where column_name=column_value; updates the data under the condition
INSERT INTO table_name (column_name1,column_name2 ...) VALUES (Column_values,column_values,...);
Query statement:
SELECT * FROM table_name where column_name=column_value; query the data that satisfies the condition based on the specific conditions
Select A.column1,a.column2,... from table_name where column_name=column_value; query data for some fields based on criteria
There are also sub-queries, sequences, views, and indexes.
MySQL Database common statements