sqlserver课程设计宿舍管理系统的增删改查代码
时间: 2023-07-19 10:09:40 浏览: 96
Java+SQL server 学生宿舍管理系统 数据库课程设计 简单控制台输出功能 增删查改统计
以下是一个简单的宿舍管理系统的增删改查的代码示例,供参考:
1. 插入学生信息
```sql
INSERT INTO Student (StudentID, Name, Gender, Age, Department, Major)
VALUES (1, '张三', '男', 20, '计算机科学与技术', '软件工程');
```
2. 修改学生信息
```sql
UPDATE Student
SET Name = '李四', Age = 21
WHERE StudentID = 1;
```
3. 删除学生信息
```sql
DELETE FROM Student
WHERE StudentID = 1;
```
4. 查询学生信息
```sql
SELECT *
FROM Student
WHERE Age > 18;
```
5. 插入宿舍信息
```sql
INSERT INTO Dormitory (DormitoryID, BuildingID, Floor, RoomNumber, Capacity)
VALUES (1, 1, 1, 101, 4);
```
6. 修改宿舍信息
```sql
UPDATE Dormitory
SET Capacity = 6
WHERE DormitoryID = 1;
```
7. 删除宿舍信息
```sql
DELETE FROM Dormitory
WHERE DormitoryID = 1;
```
8. 查询宿舍信息
```sql
SELECT *
FROM Dormitory
WHERE BuildingID = 1 AND Capacity >= 4;
```
9. 插入入住信息
```sql
INSERT INTO CheckIn (CheckInID, StudentID, DormitoryID, CheckInDate)
VALUES (1, 1, 1, '2022-01-01');
```
10. 修改入住信息
```sql
UPDATE CheckIn
SET CheckOutDate = '2022-01-10'
WHERE CheckInID = 1;
```
11. 删除入住信息
```sql
DELETE FROM CheckIn
WHERE CheckInID = 1;
```
12. 查询入住信息
```sql
SELECT *
FROM CheckIn
WHERE DormitoryID = 1 AND CheckOutDate IS NULL;
```
以上是一个简单的宿舍管理系统的增删改查的代码示例,供参考。在实际开发中,您需要根据具体的需求,编写相应的 SQL 语句,实现宿舍管理系统的增删改查等功能。
阅读全文