oracle数据库sql语句示例
时间: 2024-11-08 08:12:28 浏览: 16
Oracle数据库SQL语句是用于管理和操作数据的基础。以下是几个常见的SQL语句示例:
1. **创建表(CREATE TABLE)**:
```
CREATE TABLE Employees (
EmployeeID NUMBER(4) PRIMARY KEY,
FirstName VARCHAR2(20),
LastName VARCHAR2(20),
HireDate DATE
);
```
2. **插入记录(INSERT INTO)**:
```
INSERT INTO Employees (EmployeeID, FirstName, LastName, HireDate)
VALUES (101, 'John', 'Doe', TO_DATE('2020-01-01', 'YYYY-MM-DD'));
```
3. **查询数据(SELECT)**:
```
SELECT * FROM Employees WHERE EmployeeID = 101;
```
或者
```
SELECT FirstName, LastName FROM Employees;
```
4. **更新记录(UPDATE)**:
```
UPDATE Employees SET LastName = 'Smith' WHERE EmployeeID = 101;
```
5. **删除记录(DELETE)**:
```
DELETE FROM Employees WHERE EmployeeID = 101;
```
6. **连接两个表(JOIN)**:
```
SELECT e.FirstName, e.LastName, d.DepartmentName
FROM Employees e
JOIN Departments d ON e.DepartmentID = d.DepartmentID;
```
阅读全文