sql 语句

create database StuInfo

create table Course(
Cno char(10) ,Cname char(30),Ccredit real
)
create table Score ([Cno] [nchar](10) NULL,
 [Sno] [char](10) NULL,
 [Grade] [real] NULL)
 CREATE TABLE Student(
 [Sno] [char](10) NOT NULL,
 [Sname] [nchar](10) NULL,
 [Sex] [char](10) NULL,
 [Birthday] [datetime] NULL,
 [Sdept] [nchar](10) NULL,
 [memo] [varchar](200) NULL)
insert into Student values('008','过放电','男','2012-5-2','如见','')
alter table Student add  memo varchar(200)
alter table Student  drop column memo
alter table Score alter column Sno char(10)
alter table Student alter column Sno char(10) not null
alter table Student add primary key(Sno)
alter table Student alter column memo varchar(300)
alter table Score ADD FOREIGN KEY(Sno)  REFERENCES  Student  (Sno)
delete from Student where Sno='008'


alter table Score  add constraint fk_sc1 foreign key(Sno) references Student(Sno)

原文地址:https://www.cnblogs.com/czsl/p/2758332.html