数据库中已存在名为 'S' 的对象。急!
CREATEDATABASETEST1ON(NAME='TEST1_DATA',FILENAME='C:\ProgramFiles\MicrosoftSQLServer\...
CREATE DATABASE TEST1
ON
(
NAME= 'TEST1_DATA',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\TEST1.mdf',
SIZE=5 MB,
MAXSIZE=50 MB,
FILEGROWTH=10%
)
LOG ON
(
NAME='TEST1_log',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\TEST1.ldf',
SIZE=2 MB,
MAXSIZE=5 MB,
FILEGROWTH=1 MB
);
CREATE TABLE S
(
S# char(6) NOT NULL PRIMARY KEY,
SName char(10) NOT NULL,
Age smallint,
sex char(16)
);
CREATE TABLE T
(
T# char(6) NOT NULL PRIMARY KEY,
Tname char(20) NOT NULL,
Title char(4)
);
CREATE TABLE C
(
C# char(6) NOT NULL PRIMARY KEY,
Cname char(20) NOT NULL,
T# char(6) Foreign key references T (T#)
);
CREATE TABLE SC
(
S# char(6) Foreign key references S (S#),
C# char(6) Foreign key references C (C#),
SCORE SMALLINT,
PRIMARY KEY(S#,c#)
);
CREATE TABLE Student
(Sno CHAR(5) NOT NULL UNIQUE,
Sname CHAR(20) UNIQUE,
Sage INT,
Ssex CHAR(1)
);
INSERT INTO T select '001','王林','讲师'union
select '002','伍容华','助教'union
select '003','王向荣','教授'union
select '004','李丽','讲师'union
select '005','刘明','讲师'
INSERT INTO S select 'S1','张宏','22','M'union
select 'S2','李灿','21' ,'M'union
select 'S3','王宁','21','M'union
select 'S4','沈杰','22','F'union
select 'S5','欧阳铭','20','M'union
select 'S6','吴海','23','F'union
select 'S7','刘明','19','M'union
select 'S8','王东','20','M'union
select 'S9','赵梅','18' ,'F'union
select 'S10','韩玲','21' ,'F'union
select 'S11','于娟','21','M'union
select 'S12','刘宁','20','M'
INSERT INTO C select 'C1','DBA','001' union
select 'C2', 'DBP','002' union
select 'C3','MIS','001' union
select 'C4','OS','003' union
select 'C5', 'CN','004' union
select 'C6','YR','005'
INSERT INTO SC select 'S1','C1','94' union
select 'S1','C2','95' union
select 'S1','C3','78' union
select 'S2','C1','87' union
select 'S2','C3','98' union
select 'S3','C2','87' union
select 'S3','C3','55' union
select 'S4','C1','78' union
select 'S4','C2','32' union
select 'S4','C4','78'
提示错误是在第一行,不可能已经有这个表 展开
ON
(
NAME= 'TEST1_DATA',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\TEST1.mdf',
SIZE=5 MB,
MAXSIZE=50 MB,
FILEGROWTH=10%
)
LOG ON
(
NAME='TEST1_log',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\TEST1.ldf',
SIZE=2 MB,
MAXSIZE=5 MB,
FILEGROWTH=1 MB
);
CREATE TABLE S
(
S# char(6) NOT NULL PRIMARY KEY,
SName char(10) NOT NULL,
Age smallint,
sex char(16)
);
CREATE TABLE T
(
T# char(6) NOT NULL PRIMARY KEY,
Tname char(20) NOT NULL,
Title char(4)
);
CREATE TABLE C
(
C# char(6) NOT NULL PRIMARY KEY,
Cname char(20) NOT NULL,
T# char(6) Foreign key references T (T#)
);
CREATE TABLE SC
(
S# char(6) Foreign key references S (S#),
C# char(6) Foreign key references C (C#),
SCORE SMALLINT,
PRIMARY KEY(S#,c#)
);
CREATE TABLE Student
(Sno CHAR(5) NOT NULL UNIQUE,
Sname CHAR(20) UNIQUE,
Sage INT,
Ssex CHAR(1)
);
INSERT INTO T select '001','王林','讲师'union
select '002','伍容华','助教'union
select '003','王向荣','教授'union
select '004','李丽','讲师'union
select '005','刘明','讲师'
INSERT INTO S select 'S1','张宏','22','M'union
select 'S2','李灿','21' ,'M'union
select 'S3','王宁','21','M'union
select 'S4','沈杰','22','F'union
select 'S5','欧阳铭','20','M'union
select 'S6','吴海','23','F'union
select 'S7','刘明','19','M'union
select 'S8','王东','20','M'union
select 'S9','赵梅','18' ,'F'union
select 'S10','韩玲','21' ,'F'union
select 'S11','于娟','21','M'union
select 'S12','刘宁','20','M'
INSERT INTO C select 'C1','DBA','001' union
select 'C2', 'DBP','002' union
select 'C3','MIS','001' union
select 'C4','OS','003' union
select 'C5', 'CN','004' union
select 'C6','YR','005'
INSERT INTO SC select 'S1','C1','94' union
select 'S1','C2','95' union
select 'S1','C3','78' union
select 'S2','C1','87' union
select 'S2','C3','98' union
select 'S3','C2','87' union
select 'S3','C3','55' union
select 'S4','C1','78' union
select 'S4','C2','32' union
select 'S4','C4','78'
提示错误是在第一行,不可能已经有这个表 展开
2个回答
展开全部
ireland
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你把你的表名改下就行了
追问
改了没用啊。。
追答
我昨天把你的代码运行了一下,只是在你的表名后面加了一个“1”后就可以运行建立了~是不是你改完的表名还是不能用啊?~你一段一段地运行代码,看看是哪段代码出了问题~
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询