标题:SQL中怎样把代码转换为表.
取消只看楼主
wuzhong
Rank: 1
等 级:新手上路
帖 子:233
专家分:0
注 册:2006-10-23
 问题点数:0 回复次数:5 
SQL中怎样把代码转换为表.

问大家在SQL中怎样把这段代码转换为表.
要怎么做?

kage smallint,
ktime smalldatetime);

create table room(
rid char(4) not null primary key,
rtype smallint,
rrn smallint);

create table kr(
kid char(4) not null foreign key references kh(kid),
rid char(4) not null foreign key references room(rid),
rd smallint,
rmoney int,
primary key(kid,rid),
);

insert into kh values('0001','周楠','男',20,'2007-05-08 12:35');
insert into kh values('0002','钱勇勇','男',20,'2007-05-08 12:35');
insert into kh values('0003','陆向荣','男',20,'2007-05-08 12:35');
insert into kh values('0004','周明','男',20,'2007-05-08 12:35');
insert into kh values('0005','冯树彪','男',20,'2007-05-08 12:35');
insert into kh values('0006','胥睿','男',20,'2007-05-08 12:35');

insert into room values('0001'1,2);
insert into room values('0002'2,2);
insert into room values('0003'3,2);
insert into room values('0004'4,2);
insert into room values('0005'5,2);
insert into room values('0006'6,2);

insert into kr values('0001','0001',1,null);
insert into kr values('0002','0002',2,null);
insert into kr values('0003','0003',1,null);
insert into kr values('0004','0004',1,null);
insert into kr values('0005','0006',1,null);
insert into kr values('0006','0005',1,null);

搜索更多相关主题的帖子: SQL 代码 
2007-01-14 12:23
wuzhong
Rank: 1
等 级:新手上路
帖 子:233
专家分:0
注 册:2006-10-23
得分:0 
能不能再具体一点.我对这些东西,就是空白.

2007-01-14 12:31
wuzhong
Rank: 1
等 级:新手上路
帖 子:233
专家分:0
注 册:2006-10-23
得分:0 
可是运行有错误啊,错误还是一样的.代码有错误吗?


2007-01-14 12:34
wuzhong
Rank: 1
等 级:新手上路
帖 子:233
专家分:0
注 册:2006-10-23
得分:0 

上面的代码没全.补上.


create datebase xinxi

create table kh(
kid char(4) not null primary key,
kname char(20) ,
ksex char(2) default '男' check (ksex='男' or ksex='女'),
kage smallint,
ktime smalldatetime);

create table room(
rid char(4) not null primary key,
rtype smallint,
rrn smallint);

create table kr(
kid char(4) not null foreign key references kh(kid),
rid char(4) not null foreign key references room(rid),
rd smallint,
rmoney int,
primary key(kid,rid),
);

insert into kh values('0001','周楠','男',20,'2007-05-08 12:35');
insert into kh values('0002','钱勇勇','男',20,'2007-05-08 12:35');
insert into kh values('0003','陆向荣','男',20,'2007-05-08 12:35');
insert into kh values('0004','周明','男',20,'2007-05-08 12:35');
insert into kh values('0005','冯树彪','男',20,'2007-05-08 12:35');
insert into kh values('0006','胥睿','男',20,'2007-05-08 12:35');

insert into room values('0001'1,2);
insert into room values('0002'2,2);
insert into room values('0003'3,2);
insert into room values('0004'4,2);
insert into room values('0005'5,2);
insert into room values('0006'6,2);

insert into kr values('0001','0001',1,null);
insert into kr values('0002','0002',2,null);
insert into kr values('0003','0003',1,null);
insert into kr values('0004','0004',1,null);
insert into kr values('0005','0006',1,null);
insert into kr values('0006','0005',1,null);


2007-01-14 12:35
wuzhong
Rank: 1
等 级:新手上路
帖 子:233
专家分:0
注 册:2006-10-23
得分:0 
还是不行.改了一处了.
错误还有如下:


2007-01-14 12:51
wuzhong
Rank: 1
等 级:新手上路
帖 子:233
专家分:0
注 册:2006-10-23
得分:0 

斑竹,还问一个问题,就是我看到数据库了,但是我没有看到表,怎么回事?


2007-01-14 13:20



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-115898-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.070728 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved