create table tablename(
colone 类型
.......
constraint 主键名 primary key(colname) using index tablespace spacename,
constraint 外键名 foreign key (colname) references tablename(colname));
默认主键就是索引!
colone 类型
.......
constraint 主键名 primary key(colname) using index tablespace spacename,
constraint 外键名 foreign key (colname) references tablename(colname));
默认主键就是索引!
解决方案 »
- 关于SQL字段和函数同时查询的问题
- 使用oracle net configuration assistant工具 配置本地net服务名错误
- 简单的安装问题??
- 求助Oracle 数据链连接问题
- oracle 存储过程编译成功,但执行错误,求教原因。
- 如何把一个表的多个字段合并起来.
- 谁那边有数据库维护规定啊?就是直接修改数据库里的数据,不从前台软件做的???帮帮忙啊!!!
- 启动ManagementServer 出现的情况!!
- 学习 oracle (9i的)吗?这里有视频教学
- 如何增加/修改oracle的用户连接数
- 最近数据库升级为oracle9.2.0.1 为什么操作下列语句是老是提示:
- v$nls_parameters 和 v_$nls_parameters ???
还有需要另建索引时也需要定义索引空间spacename从何而来?
create table APPLY_EXPORT_GOODS
(
HANDBOOK_ID VARCHAR2(20) not null,
LINE_NO NUMBER(4) not null,
GOODS_CODE VARCHAR2(20) not null,
DESCRIPTION VARCHAR2(30),
SPEC_UM VARCHAR2(30),
APPLY_QTY NUMBER(16,4) not null,
EXPORTED_QTY NUMBER(16,4) not null,
STOCK_UM VARCHAR2(10),
UNIT_PRICE NUMBER(16,4) not null,
APPLY_AMOUNT NUMBER(16,4) not null,
EXPORTED_AMOUNT NUMBER(16,4) not null,
STATUS VARCHAR2(10) not null,
USER_1 NUMBER(16,4) default 0,
USER_2 VARCHAR2(20),
USER_3 VARCHAR2(20),
USER_4 VARCHAR2(20) not null
)
-- Create/Recreate primary, unique and foreign key constraints
alter table APPLY_EXPORT_GOODS
add constraint APPLY_EXPORT_PK primary key (HANDBOOK_ID,LINE_NO);
alter table APPLY_EXPORT_GOODS
add constraint APPLY_EXPORT_FK foreign key (HANDBOOK_ID)
references HANDBOOK (ID);
-- Create/Recreate indexes
create index IDX_APPLY_EXPORT on APPLY_EXPORT_GOODS (HANDBOOK_ID,LINE_NO)
下面这段的 EM_DATA是什么时候定义的?tablespace EM_DATA
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
create table P_ZJRB
(
WELLNO VARCHAR2(20) not null,
USEUNITID VARCHAR2(18) not null,
RBXH NUMBER(10) not null,
RBRQ DATE,
ZZRQ DATE,
ZZJS NUMBER(8,2),
LJJC NUMBER(8,2),
DC VARCHAR2(20),
ZTXINGH VARCHAR2(20),
ZTXJ VARCHAR2(1) default '1',
ZTCC NUMBER(8,2),
QSJS NUMBER(8,2),
GZNR VARCHAR2(1000),
ZDTS VARCHAR2(60),
ANJL VARCHAR2(24),
ZBGB VARCHAR2(24),
GZZT VARCHAR2(20),
ZS NUMBER(4),
BY1 NUMBER(6,1),
PL NUMBER(6,2),
ZY NUMBER(4),
ZJYMD NUMBER(4,2),
QYJS NUMBER(8,2),
SXZD NUMBER(5,1),
HSL NUMBER(4,1),
ZYSS NUMBER(5,1),
NB NUMBER(5,2),
QL10M NUMBER(5,1),
QL10F NUMBER(5,1),
DQL NUMBER(8,2),
PHZ NUMBER(3,1),
LDZD NUMBER(4),
XZZDJ3ZD NUMBER(4,1),
XZZDJ300 NUMBER(4,1),
XZZDJ600 NUMBER(4,1),
BSFLAG VARCHAR2(1),
COMNAME VARCHAR2(30),
ZJRBSHR VARCHAR2(24)
)
tablespace USERS
pctfree 10
pctused 40
initrans 1
maxtrans 255
storage
(
initial 18688K
next 128K
minextents 1
maxextents unlimited
pctincrease 0
);
-- Add comments to the table
comment on table P_ZJRB
is '钻井日报';
-- Add comments to the columns
comment on column P_ZJRB.WELLNO
is '单井编码';
comment on column P_ZJRB.USEUNITID
is '机构编码';
comment on column P_ZJRB.RBXH
is '日报序号';
comment on column P_ZJRB.RBRQ
is '日报日期';
comment on column P_ZJRB.ZZRQ
is '终止日期';
comment on column P_ZJRB.ZZJS
is '终止井深';
comment on column P_ZJRB.LJJC
is '全日累计进尺';
comment on column P_ZJRB.DC
is '地层';
comment on column P_ZJRB.ZTXINGH
is '钻头型号';
comment on column P_ZJRB.ZTXJ
is '钻头新旧';
comment on column P_ZJRB.ZTCC
is '钻头尺寸';
comment on column P_ZJRB.QSJS
is '起始井深';
comment on column P_ZJRB.GZNR
is '工作内容';
comment on column P_ZJRB.ZDTS
is '重点提示';
comment on column P_ZJRB.ANJL
is '安全监理';
comment on column P_ZJRB.ZBGB
is '值班干部';
comment on column P_ZJRB.GZZT
is '工作状态';
comment on column P_ZJRB.ZS
is '转数';
comment on column P_ZJRB.BY1
is '泵压';
comment on column P_ZJRB.PL
is '排量';
comment on column P_ZJRB.ZY
is '钻压';
comment on column P_ZJRB.ZJYMD
is '钻井液密度';
comment on column P_ZJRB.QYJS
is '取样井深';
comment on column P_ZJRB.SXZD
is '塑性粘度';
comment on column P_ZJRB.HSL
is '含砂量';
comment on column P_ZJRB.ZYSS
is '失水';
comment on column P_ZJRB.NB
is '泥饼';
comment on column P_ZJRB.QL10M
is '初切(10秒静切力)';
comment on column P_ZJRB.QL10F
is '终切(10分切力)';
comment on column P_ZJRB.DQL
is '动切力';
comment on column P_ZJRB.PHZ
is 'PH值';
comment on column P_ZJRB.LDZD
is '漏斗粘度';
comment on column P_ZJRB.XZZDJ3ZD
is '旋转粘度计3转读数';
comment on column P_ZJRB.XZZDJ300
is '旋转粘度计300转读数';
comment on column P_ZJRB.XZZDJ600
is '旋转粘度计600转读数';
comment on column P_ZJRB.BSFLAG
is '报送标志';
comment on column P_ZJRB.COMNAME
is '公司名称(储存井队上级机构ID号)';
comment on column P_ZJRB.ZJRBSHR
is '审核人';
-- Create/Recreate primary, unique and foreign key constraints
alter table P_ZJRB
add constraint PK_P_ZJRB primary key (WELLNO,USEUNITID,RBXH)
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 6528K
next 128K
minextents 1
maxextents unlimited
pctincrease 0
);
alter table P_ZJRB
add constraint FK_P_ZJRB_RELATIONS_USEUNITC foreign key (USEUNITID)
references USEUNITCODE (USEUNITID) on delete cascade;
-- Create/Recreate indexes
create index RELATIONSHIP_127_FK on P_ZJRB (WELLNO)
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 4M
next 128K
minextents 1
maxextents unlimited
pctincrease 0
);
create index RELATIONSHIP_128_FK on P_ZJRB (USEUNITID)
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 4608K
next 128K
minextents 1
maxextents unlimited
pctincrease 0
);
USERS
这个表空间的含义究竟是什么?
搞明白了这个问题就结帖
USERS
这个表空间名称的含义究竟是什么?
搞明白了这个问题就结帖
创建表空间
create tablespace spname datafile 'c:\oracle\datafile\data1.ora'
size 10M ...;
您理解错了,我想知道表空间USERS 和前面老兄用到的EM_DATA有什么不同,既然在下面给出了详细定义了,为什么还要指定名称?
( 编码 VARCHAR2(8),
名称 VARCHAR2(40),
简码 VARCHAR2(40),
地址 varchar2(50),
联系人 varchar2(20),
联系方式 varchar2(20))
PCTFREE 5
PCTUSED 90
STORAGE (INITIAL 256 NEXT 128 PCTINCREASE 0)
TABLESPACE MErc;
ALTER TABLE 生产商 ADD CONSTRAINT 生产商_UQ_编码 UNIQUE (编码) USING INDEX PCTFREE 10 TABLESPACE MErc;
ALTER TABLE 生产商 ADD CONSTRAINT 生产商_UQ_名称 UNIQUE (名称) USING INDEX PCTFREE 10 TABLESPACE MErc;
create public synonym 生产商 for 生产商;
是不是这个样子的。
另外如果用的话再加其它的外键。