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