orcel常用语句教程
时间: 2024-01-25 11:03:13 浏览: 67
Oracle 常用 SQL 语句教程:
1. 创建表:
```
CREATE TABLE table_name (
column1 datatype [ NULL | NOT NULL ],
column2 datatype [ NULL | NOT NULL ],
...
columnN datatype [ NULL | NOT NULL ]
);
```
2. 修改表:
```
ALTER TABLE table_name
ADD column_name datatype;
ALTER TABLE table_name
MODIFY column_name datatype;
ALTER TABLE table_name
DROP COLUMN column_name;
```
3. 插入数据:
```
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
```
4. 更新数据:
```
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
```
5. 删除数据:
```
DELETE FROM table_name WHERE condition;
```
6. 查询数据:
```
SELECT column1, column2, ... FROM table_name WHERE condition;
```
7. 排序:
```
SELECT column1, column2, ...
FROM table_name
ORDER BY column1 [ASC | DESC], column2 [ASC | DESC], ...;
```
8. 分组:
```
SELECT column1, COUNT(column2)
FROM table_name
GROUP BY column1;
```
9. 连接:
```
SELECT column1, column2, ...
FROM table1
JOIN table2
ON table1.column_name = table2.column_name;
```
10. 子查询:
```
SELECT column1, column2, ...
FROM table_name
WHERE column_name IN (SELECT column_name FROM table_name2 WHERE condition);
```
阅读全文