创建表 (CREATE TABLE
):
CREATE TABLE table_name (
column1 data_type constraint,
column2 data_type constraint,
... );
插入数据 (INSERT INTO
):
INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
查询数据 (SELECT
):
SELECT column1, column2, ... FROM table_name WHERE condition;
更新数据 (UPDATE
):
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition;
删除数据 (DELETE
):
DELETE FROM table_name WHERE condition;
修改表结构 (ALTER TABLE
):
添加列:
ALTER TABLE table_name ADD COLUMN column_name data_type;
删除列:
ALTER TABLE table_name DROP COLUMN column_name;
修改列的数据类型:
ALTER TABLE table_name ALTER COLUMN column_name TYPE new_data_type;
重命名列:
ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;
重命名表 (RENAME
):
ALTER TABLE old_table_name RENAME TO new_table_name;
删除表 (DROP TABLE
):
DROP TABLE table_name;
创建索引 (CREATE INDEX
):
CREATE INDEX index_name ON table_name (column_name);
删除索引 (DROP INDEX
):
DROP INDEX index_name;
创建视图 (CREATE VIEW
):
CREATE VIEW view_name AS SELECT column1, column2, ... FROM table_name WHERE condition;
删除视图 (DROP VIEW
):
DROP VIEW view_name;