SQL server語句測試

來源:互聯網
上載者:User

標籤:

設有一資料庫,包括四個表:學生表(Student)、課程表(Course)、成績表(Score)以及教師資訊表(Teacher)。四個表的結構分別如表1-1的表(一~表(四)所示,資料如表1-2的表(一)~表(四)所示。用SQL語句建立四個表並完成相關題目。

create database ceshi
go

use ceshi
go
create table Student
(
SnoChar(3)primary key,
Sname Char(8),
Ssex Char(2),
Sbirthday datetime,
Class Char(5)
)
go
create table Course
(
CnoChar(5)primary key,
Cname Varchar(10),
TnoChar(3)
)
go
create table Score
(
SnoChar(3),
CnoChar(5),
Degree Decimal(4,1)
)
go
create table Teacher
(
TnoChar(3)primary key,
Tname Char(4),
Tsex Char(2),
Tbirthday datetime,
Prof Char(6),
Depart Varchar(10)
)
go
insert into Student values(108,‘曾華‘,‘男‘,‘1977-09-01‘,‘95033‘)
insert into Student values(105,‘匡明‘,‘男‘,‘1975-10-02‘,‘95031‘)
insert into Student values(107,‘王麗‘,‘女‘,‘1976-01-23‘,‘95033‘)
insert into Student values(101,‘李軍‘,‘男‘,‘1976-02-20‘,‘95033‘)
insert into Student values(109,‘王芳‘,‘女‘,‘1975-02-10‘,‘95031‘)
insert into Student values(103,‘陸君‘,‘男‘,‘1974-06-03‘,‘95031‘)
go
insert into Course values(‘3-105‘,‘電腦導論‘,825)
insert into Course values(‘3-245‘,‘作業系統‘,804)
insert into Course values(‘6-166‘,‘數字電路‘,856)
insert into Course values(‘9-888‘,‘高等數學‘,831)
go
insert into Score values(103,‘3-245‘,86)
insert into Score values(105,‘3-245‘,75)
insert into Score values(109,‘3-245‘,68)
insert into Score values(103,‘3-105‘,92)
insert into Score values(105,‘3-105‘,88)
insert into Score values(109,‘3-105‘,76)
insert into Score values(101,‘3-105‘,64)
insert into Score values(107,‘3-105‘,91)
insert into Score values(108,‘3-105‘,78)
insert into Score values(101,‘6-166‘,85)
insert into Score values(107,‘6-166‘,79)
insert into Score values(108,‘6-166‘,81)
go
insert into Teacher values(804,‘李誠‘,‘男‘,‘1985-12-02‘,‘副教授‘,‘電腦系‘)
insert into Teacher values(856,‘張旭‘,‘男‘,‘1969-03-12‘,‘講師‘,‘電子工程系‘)
insert into Teacher values(825,‘王萍‘,‘女‘,‘1972-05-05‘,‘助教‘,‘電腦系‘)
insert into Teacher values(831,‘劉冰‘,‘女‘,‘1977-08-14‘,‘助教‘,‘電子工程系‘)
go

SQL server語句測試

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.