这是我用PD生成的数据库设计代码,请帮我检查哈,该怎么改,小弟万分感谢if exists(select 1 from sys.sysforeignkey where role='FK_RELATION_RELATIONS_会员表') then
alter table Relationship_1
delete foreign key FK_RELATION_RELATIONS_会员表
end if;if exists(select 1 from sys.sysforeignkey where role='FK_RELATION_RELATIONS_商品表') then
alter table Relationship_1
delete foreign key FK_RELATION_RELATIONS_商品表
end if;if exists(select 1 from sys.sysforeignkey where role='FK_会员表_INHERITAN_收货信息表') then
alter table 会员表
delete foreign key FK_会员表_INHERITAN_收货信息表
end if;if exists(select 1 from sys.sysforeignkey where role='FK_商品表_RELATIONS_订单信息表') then
alter table 商品表
delete foreign key FK_商品表_RELATIONS_订单信息表
end if;if exists(select 1 from sys.sysforeignkey where role='FK_收货信息表_RELATIONS_会员表') then
alter table 收货信息表
delete foreign key FK_收货信息表_RELATIONS_会员表
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_1_FK2'
and t.table_name='Relationship_1'
) then
drop index Relationship_1.Relationship_1_FK2
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_1_FK'
and t.table_name='Relationship_1'
) then
drop index Relationship_1.Relationship_1_FK
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_1_PK'
and t.table_name='Relationship_1'
) then
drop index Relationship_1.Relationship_1_PK
end if;if exists(
select 1 from sys.systable
where table_name='Relationship_1'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table Relationship_1
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Inheritance_1_FK'
and t.table_name='会员表'
) then
drop index 会员表.Inheritance_1_FK
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='会员表_PK'
and t.table_name='会员表'
) then
drop index 会员表.会员表_PK
end if;if exists(
select 1 from sys.systable
where table_name='会员表'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table 会员表
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_3_FK'
and t.table_name='商品表'
) then
drop index 商品表.Relationship_3_FK
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='商品表_PK'
and t.table_name='商品表'
) then
drop index 商品表.商品表_PK
end if;if exists(
select 1 from sys.systable
where table_name='商品表'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table 商品表
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_2_FK'
and t.table_name='收货信息表'
) then
drop index 收货信息表.Relationship_2_FK
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='收货信息表_PK'
and t.table_name='收货信息表'
) then
drop index 收货信息表.收货信息表_PK
end if;if exists(
select 1 from sys.systable
where table_name='收货信息表'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table 收货信息表
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='订单信息表_PK'
and t.table_name='订单信息表'
) then
drop index 订单信息表.订单信息表_PK
end if;if exists(
select 1 from sys.systable
where table_name='订单信息表'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table 订单信息表
end if;
alter table Relationship_1
delete foreign key FK_RELATION_RELATIONS_会员表
end if;if exists(select 1 from sys.sysforeignkey where role='FK_RELATION_RELATIONS_商品表') then
alter table Relationship_1
delete foreign key FK_RELATION_RELATIONS_商品表
end if;if exists(select 1 from sys.sysforeignkey where role='FK_会员表_INHERITAN_收货信息表') then
alter table 会员表
delete foreign key FK_会员表_INHERITAN_收货信息表
end if;if exists(select 1 from sys.sysforeignkey where role='FK_商品表_RELATIONS_订单信息表') then
alter table 商品表
delete foreign key FK_商品表_RELATIONS_订单信息表
end if;if exists(select 1 from sys.sysforeignkey where role='FK_收货信息表_RELATIONS_会员表') then
alter table 收货信息表
delete foreign key FK_收货信息表_RELATIONS_会员表
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_1_FK2'
and t.table_name='Relationship_1'
) then
drop index Relationship_1.Relationship_1_FK2
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_1_FK'
and t.table_name='Relationship_1'
) then
drop index Relationship_1.Relationship_1_FK
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_1_PK'
and t.table_name='Relationship_1'
) then
drop index Relationship_1.Relationship_1_PK
end if;if exists(
select 1 from sys.systable
where table_name='Relationship_1'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table Relationship_1
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Inheritance_1_FK'
and t.table_name='会员表'
) then
drop index 会员表.Inheritance_1_FK
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='会员表_PK'
and t.table_name='会员表'
) then
drop index 会员表.会员表_PK
end if;if exists(
select 1 from sys.systable
where table_name='会员表'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table 会员表
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_3_FK'
and t.table_name='商品表'
) then
drop index 商品表.Relationship_3_FK
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='商品表_PK'
and t.table_name='商品表'
) then
drop index 商品表.商品表_PK
end if;if exists(
select 1 from sys.systable
where table_name='商品表'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table 商品表
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='Relationship_2_FK'
and t.table_name='收货信息表'
) then
drop index 收货信息表.Relationship_2_FK
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='收货信息表_PK'
and t.table_name='收货信息表'
) then
drop index 收货信息表.收货信息表_PK
end if;if exists(
select 1 from sys.systable
where table_name='收货信息表'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table 收货信息表
end if;if exists(
select 1 from sys.sysindex i, sys.systable t
where i.table_id=t.table_id
and i.index_name='订单信息表_PK'
and t.table_name='订单信息表'
) then
drop index 订单信息表.订单信息表_PK
end if;if exists(
select 1 from sys.systable
where table_name='订单信息表'
and table_type in ('BASE', 'GBL TEMP')
) then
drop table 订单信息表
end if;
if ..... then
把 then 去掉,sql 语法中没 then.
2.
delete foreign key ....
改为
drop keyname
if ....
......
end if
用:
if .....
begin
......
end
delete foreign key ....
改为
drop keyname
提示错误
drop constrainname
现在我要创建这样一个数据库
create database yougouxitong on primary
(name='yougouxitong_data',filename='C:\新建文件夹',size=4096KB,maxsize=unlimited,filegrowth=10%)
log
on
(name='yougouxitong_log',filename='C:\新建文件夹',size=1024KB,maxsize=5120KB,filegrowth=2048KB)
但是出现这样提示:
消息 1802,级别 16,状态 4,第 1 行
CREATE DATABASE 失败。无法创建列出的某些文件名。请查看相关错误。
消息 5123,级别 16,状态 1,第 1 行
尝试打开或创建物理文件 'C:\新建文件夹' 时,CREATE FILE 遇到操作系统错误 5(拒绝访问。)。这是怎么回事呢?