国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > SQL Server > 正文

通過T_sql語句向其中一次填入一條數據或一次填入多條數據的方式

2024-08-31 00:44:49
字體:
來源:轉載
供稿:網友
使用T_SQL創建數據庫 TestSchool

創建一個學生表 TblStudent

創建學生成績表 TblScore q tScoreId (成績 id, 主鍵 , 自動編號)、 tSId (學生編號)、 tEnglish (英語成績)、 tMath (數學成績)
創建老師表 TblTeacher q tTId 、 tTName 、 tTGender 、 tTAge 、 tTSalary 、 tTBirthday
并使用T_sql語句向其中一次填入一條數據或一次填入多條數據的方式填入數據。

1)Insert into 表(列) select 列 1 ,列 2 union
2)Insert into 表(列) select 列 1 ,列 2 from 表
3) Select 列 into 新表名 from 舊表

復制代碼 代碼如下:


create database TestSchool
on primary
(
name='TestSchool',
filename='F:/SQL Server/TestSchool.mdf',
size=10mb,
filegrowth=10,
maxsize=100mb
)
log on
(
name='TestSchool_log',
filename='F:/SQL Server/TestSchool_log.ldf'
)

create table TblStudent
(
studentId int identity(1,1) primary key,
tScoreId int not null,
sName nvarchar(50) not null,
sAge int not null,
sNo numeric(18,0),--身份證號,十八位數字,小數位0
sEmail varchar(50),
sGender bit default(1),
sBirthday datetime
)

select * from TblStudent
truncate table TblStudent

insert into TblStudent
select 1,'劉備',20,123456789012345678,'123@163.com',1,'1987-5-6' union
select 1,'關羽',19,123456789012345671,'1sfdsf3@163.com',1,'1988-8-6' union
select 1,'張飛',18,123456789012345672,'12sfsd3@163.com',1,'1989-5-19' union
select 4,'曹操',22,123456789012345673,'12sf3@163.com',1,'1985-12-6' union
select 4,'夏侯

主站蜘蛛池模板: 苏尼特左旗| 灵川县| 东乡县| 咸宁市| 临西县| 翁源县| 隆尧县| 县级市| 太保市| 临江市| 天台县| 扬州市| 嘉祥县| 磐安县| 静乐县| 翁牛特旗| 武汉市| 家居| 应城市| 曲周县| 阜宁县| 克东县| 二连浩特市| 漠河县| 澜沧| 宁武县| 财经| 文水县| 霞浦县| 盐城市| 花莲县| 和政县| 亚东县| 尖扎县| 仁怀市| 夹江县| 宣汉县| 龙井市| 宁津县| 淮阳县| 筠连县|