溫馨提示×

常用的mysql命令語句有哪些

小億
92
2023-06-05 16:35:39
欄目: 云計算

  1. 創(chuàng)建數(shù)據(jù)庫:CREATE DATABASE database_name;

  2. 刪除數(shù)據(jù)庫:DROP DATABASE database_name;

  3. 選擇數(shù)據(jù)庫:USE database_name;

  4. 創(chuàng)建表:CREATE TABLE table_name (column_name1 data_type1, column_name2 data_type2, …);

  5. 刪除表:DROP TABLE table_name;

  6. 插入數(shù)據(jù):INSERT INTO table_name (column_name1, column_name2, …) VALUES (value1, value2, …);

  7. 更新數(shù)據(jù):UPDATE table_name SET column_name1 = value1, column_name2 = value2 WHERE condition;

  8. 刪除數(shù)據(jù):DELETE FROM table_name WHERE condition;

  9. 查詢數(shù)據(jù):SELECT column_name1, column_name2, … FROM table_name WHERE condition;

  10. 查詢表結(jié)構(gòu):DESCRIBE table_name;

  11. 添加主鍵:ALTER TABLE table_name ADD PRIMARY KEY (column_name);

  12. 添加外鍵:ALTER TABLE table_name ADD FOREIGN KEY (column_name) REFERENCES other_table(column_name);

  13. 修改表結(jié)構(gòu):ALTER TABLE table_name MODIFY column_name data_type;

  14. 清空表數(shù)據(jù):TRUNCATE TABLE table_name;

  15. 查看當(dāng)前版本:SELECT VERSION();

0