怎样创建学生数据库用T-SQL语句

怎样创建学生数据库用T-SQL语句,第1张

create table xs(

Sno char(7) not null primary key,

Sname char(10) not null,

Ssex char(2),

Sage smallint,

Sdept char(20)

)

create table kc(

Cno char(6) primary key,

Cname char(20) not null,

Credit tinyint,

Semester tinyint

)

create table cj(

Sno char(7) not null,

Cno char(6) not null,

Grade tinyint

foreign key(Sno) references xs(Sno),

foreign key(Cno) references kc(Cno)

)

1.

USE [master]

GO

CREATE DATABASE [active] ON PRIMARY

( NAME = N'arch1', FILENAME = N'D:\arch1.mdf' , SIZE = 5120KB , MAXSIZE = 51200KB , FILEGROWTH = 1024KB )

LOG ON

( NAME = N'archlog1', FILENAME = N'D:\archlog1.ldf' , SIZE = 1024KB , MAXSIZE = 51200KB , FILEGROWTH = 1024KB )

COLLATE Chinese_PRC_CI_AS

GO

2.

USE [master]

GO

DROP DATABASE active

3.

USE [master]

GO

CREATE DATABASE 学生 ON PRIMARY

( NAME = N'学生', FILENAME = N'D:\学生.mdf' , SIZE = 5120KB , MAXSIZE = 51200KB , FILEGROWTH = 1024KB )

LOG ON

( NAME = N'学生_log', FILENAME = N'D:\学生_log.ldf' , SIZE = 1024KB , MAXSIZE = 5120KB, FILEGROWTH = 1024KB )

COLLATE Chinese_PRC_CI_AS

GO

USE [学生]

GO

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE TABLE [dbo].[学生信息](

[RID] [int] NULL

) ON [PRIMARY]

几个表的创建方式都一样 不在赘述... 希望有点帮助


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/6775580.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-28
下一篇 2023-03-28

发表评论

登录后才能评论

评论列表(0条)

保存