sql server语句示范,给我实例写出来
时间: 2024-09-20 07:11:55 浏览: 33
《C语言和SQLServer数据库技术基础》课程标准基本信息(高职).docx
SQL Server是一种关系型数据库管理系统,它的基本语句包括查询数据、插入更新删除记录等。这里有一些常见的SQL Server语句示例:
1. **查询数据** (SELECT语句):
```sql
SELECT * FROM Customers; -- 查询Customers表中的所有列
SELECT FirstName, LastName FROM Employees WHERE Department = 'Sales'; -- 根据部门筛选员工信息
```
2. **插入新记录** (INSERT语句):
```sql
INSERT INTO Employees (FirstName, LastName, Position) VALUES ('John', 'Doe', 'Manager'); -- 插入一条新员工信息
```
3. **更新记录** (UPDATE语句):
```sql
UPDATE Customers SET Email = 'newemail@example.com' WHERE CustomerID = 1;
```
4. **删除记录** (DELETE语句):
```sql
DELETE FROM Orders WHERE OrderDate < '2021-01-01'; -- 删除2021年前的所有订单
```
5. **创建表** (CREATE TABLE语句):
```sql
CREATE TABLE Employees (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Department VARCHAR(50)
);
```
阅读全文