基本SQL資料表 學生 老師 課程 成績

2021-10-05 22:04:11 字數 4556 閱讀 4538

create  table student--建立student資料表

( s_no char(10) not null, --學號

s_name nchar(10), --姓名

s_*** char(2), --性別

borndate smalldatetime,--出生日期

classname nvarchar(50), --班級名稱

telephone varchar(11), --**號碼

enrolldate smalldatetime,--註冊日期

address nvarchar(50), --位址

comment text --備註

)create table teacher

( t_no char(10) not null,

t_name nchar(10),

t_*** char(2),

borndate smalldatetime,

dept_no char(10)

)create table course

( c_no char(10) not null,

c_name nvarchar(30),

c_type nchar(10),

c_credit decimal(5,1),

c_des text

)create table t_user

( username char(10) not null,

password char(10),

grade nchar(10),

description text

)create table t_c

( t_no char(10) not null,

c_no char(10) not null,

semester nvarchar(30)

)create table s_c

( s_no char(10) not null,

c_no char(10) not null,

score int

)create table dept

( d_no char(10) not null,

deptname nvarchar(20),

duty nvarchar(50)

)use stu

go--修改資料表

alter table student

add idcard char(18) --增加身份證列

--修改資料表刪除列

alter table student

drop column idcard

--修改資料表修改資料型別

alter table student

alter column borndate datetime

--插入資料

--向student表中插入資料

insert into student values('05331101','張曼','女','1993-05-03 00:00:00',

'計算機應用','18602354822','2005-09-01 00:00:00','遼寧瀋陽',null)

insert into student values('05331102','劉迪','女','1994-10-20 00:00:00',

'計算機應用','13893220935','2005-09-01 00:00:00','遼寧撫順',null)

insert into student values('05331103','劉凱','男','1982-05-30 00:00:00',

'計算機應用','18641330245','2005-09-01 00:00:00','遼寧鞍山',null)

insert into student values('05331104','王越','男','1991-09-19 00:00:00',

'計算機應用','18641320940','2005-09-01 00:00:00','遼寧營口',null)

insert into student values('05331105','李楠','女','1995-03-16 00:00:00',

'計算機應用','18641328449','2005-09-01 00:00:00','遼寧錦州',null)

insert into student values('05331106','胡棟','男','1992-07-03 00:00:00',

'計算機應用','18641326996','2005-09-01 00:00:00','遼寧瀋陽',null)

insert into student values('06102534','楊超','男','1990-10-01 00:00:00',

'機械設計','13893245623','2006-09-01 00:00:00','河北石家莊',null)

--向教師表中插入資料

insert into teacher values('0001','王慶','男','1965-3-9','1')

insert into teacher values('0002','林志玲','女','1980-7-12','2')

insert into teacher values('0003','黎明','男','1975-5-18','3')

insert into teacher values('0004','郭靖','男','1953-10-30','4')

insert into teacher values('0005','黃蓉','女','1973-8-27','1')

insert into teacher values('0006','林黛玉','女','1983-5-27','2')

--向成績表中錄入資料

insert into s_c values('05331101','0001',95)

insert into s_c values('05331101','0002',98)

insert into s_c values('05331101','0003',89)

insert into s_c values('05331102','0001',93)

insert into s_c values('05331102','0002',99)

insert into s_c values('05331102','0003',95)

insert into s_c values('05331103','0001',84)

insert into s_c values('05331103','0002',80)

insert into s_c values('05331103','0003',94)

--向部門表中插入資料

insert into dept values('1','人事處','處理人事工作')

insert into dept values('2','學生處','處理學生工作')

insert into dept values('3','教務處','處理教學相關工作')

insert into dept values('4','校園管理處','處理學校所有後勤輔助工作')

insert into dept values('5','機械與運載學院','教學單位')

insert into dept values('6','資訊與控制學院','教學單位')

insert into dept values('7','經濟與管理學院','教學單位')

--向課程表中插入資料

insert into course values('0001','大學英語','考試','10','英語相關知識')

insert into course values('0002','資料庫原理及應用','考試','7','資料庫相關知識')

insert into course values('0003','資料結構','考查','5','程式設計基礎')

--向授課表中插入資料

insert into t_c values('0001','0001','2011-2012(1)')

insert into t_c values('0001','0002','2011-2012(2)')

insert into t_c values('0002','0001','2011-2012(1)')

insert into t_c values('0003','0001','2011-2012(1)')

insert into t_c values('0004','0002','2011-2012(2)')

insert into t_c values('0005','0002','2011-2012(2)')

insert into t_c values('0006','0003','2011-2012(2)')

insert into t_c values('0006','0002','2011-2012(1)')

學生管理系統資料表

學生表 tb student 欄位名字段型別 字段說明 是否為空 其他id int學生表主鍵否自增 name char 32 學生姓名 否innerno int班內序號 否pwd char 32 密碼否 gradeid int年級 外來鍵 否classid int班級 外來鍵 否 char 32 性...

sql資料表分割槽

一般情況下,我們建立資料庫表時,表資料都存放在乙個檔案裡。但是如果是分割槽表的話,表資料 就會按照你指定的規則分放到不同的檔案裡,把乙個大的資料檔案拆分為多個小檔案,還可以把這些小檔案放在不同的磁碟下由多個cpu進行處理 分割槽函式,將資料對映到一組分割槽上。create partition fun...

SQL 資料表建立

3.insert into 新增資料 4.update 修改資料 5.delete 刪除資料 結構和約束還在 6.drop 刪除表 軟體環境 oracle 12c 1.create table 建立表 語法格式 create table 方案.表 欄位名1 資料類 字段級別約束條 default 預...