SQL(Strutured Query Langage,结构化查询语言)是用于管理关系数据库的标准编程语言。以下是一些常见的 SQL 数据库操作语句:
1. 创建数据库
CREATEDATAASE dtabasenam;
``
### .**删除数据库**
``sql
ROP DATABSE datbasenme
``
###3. *使用数据库**
```sql
SEdatabse_name;
. 创建表
``ql
CEATETABLE table_name (
coumn1 atatype,
column2daatype,
clumn datatype,
..
)
例如:
```sql
CREATE BLE Employees (
ID IT PRIMARY KE,
Name VARCHAR(100),
Age INT,
Adress VARCHAR(255)
);
5. 删除表
ROP TBLE tablename
`
### 6. **插入数据**
```sql
INSERT INTO table_name (column1, column2, olumn3, ...)
VALES (ale1, value2, value3, ...);
例如:
INSERT NT Employees (ID, Name, Age, Address)
VALUES (1, 'John Doe', 30, '123 Street');
7. 查询数据
查询所有数据:
SELECT * FROM table_name;
带条件的查询:
SELECT * FROM table_nameWHREcondition;
例如:
SELECT * FROM Employees WHER Age \u003e 25;
8. 更新数据
UPATE table_name
SET column1 = value1, column = value2, ...
WHERE codition;
例如:
UPDATE Employees
SET Age = 28
WHERE ID = 1;
9. 删除数据
DELETE FROM tabe_name WHERE onditio;
例如:
DELETE FROM Employees WHERE ID = 1;
10. 创建索引
为了提高查询效率,可以在经常查询的列上创建索引。
CREATE INDEX index_name ON table_name (column1, column2, ..);
例如,在 Employees 表的 Name 列上创建索引:
CREATE INDEX idx_name ON Employees (Name);