status: Idea tags: 数据库 Created time: August 27, 2023 9:59 PM
MySQL是一个常用的关系型数据库管理系统,下面列举一些MySQL常用的语法:
创建数据库:
CREATE DATABASE database_name;
创建表:
CREATE TABLE table_name (
column1 datatype constraints,
column2 datatype constraints,
...
);
插入数据:
INSERT INTO table_name (column1, column2, ...)
VALUES (value1, value2, ...);
查询数据:
SELECT column1, column2, ...
FROM table_name
WHERE conditions;
更新数据:
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE conditions;
删除数据:
DELETE FROM table_name
WHERE conditions;
添加列:
ALTER TABLE table_name
ADD column_name datatype constraints;
修改列:
ALTER TABLE table_name
MODIFY column_name datatype constraints;
删除列:
ALTER TABLE table_name
DROP COLUMN column_name;
创建索引:
CREATE INDEX index_name
ON table_name (column1, column2, ...);
删除索引:
DROP INDEX index_name
ON table_name;