創(chuàng)建數(shù)據(jù)庫:CREATE DATABASE database_name;
刪除數(shù)據(jù)庫:DROP DATABASE database_name;
選擇數(shù)據(jù)庫:USE database_name;
創(chuàng)建表:CREATE TABLE table_name (column_name1 data_type1, column_name2 data_type2, …);
刪除表:DROP TABLE table_name;
插入數(shù)據(jù):INSERT INTO table_name (column_name1, column_name2, …) VALUES (value1, value2, …);
更新數(shù)據(jù):UPDATE table_name SET column_name1 = value1, column_name2 = value2 WHERE condition;
刪除數(shù)據(jù):DELETE FROM table_name WHERE condition;
查詢數(shù)據(jù):SELECT column_name1, column_name2, … FROM table_name WHERE condition;
查詢表結(jié)構(gòu):DESCRIBE table_name;
添加主鍵:ALTER TABLE table_name ADD PRIMARY KEY (column_name);
添加外鍵:ALTER TABLE table_name ADD FOREIGN KEY (column_name) REFERENCES other_table(column_name);
修改表結(jié)構(gòu):ALTER TABLE table_name MODIFY column_name data_type;
清空表數(shù)據(jù):TRUNCATE TABLE table_name;
查看當(dāng)前版本:SELECT VERSION();