CREATE TABLE table_name20160927103238(
miji VARCHAR2(100) NOT NULL UNIQUE,
bumen VARCHAR2(100) NOT NULL UNIQUE,
h VARCHAR2(100) DEFAULT 'j7j' NOT NULL,
juj NUMBER(22) NOT NULL);
COMMENT ON table table_name20160927103238 IS '文件j7';
COMMENT ON COLUMN table_name20160927103238.miji IS '密级';
COMMENT ON COLUMN table_name20160927103238.bumen IS '部门';
COMMENT ON COLUMN table_name20160927103238.h IS 'jj7j';
COMMENT ON COLUMN table_name20160927103238.juj IS 'jjj';
c
ALTER TABLE table_name20160927103238 ADD PRIMARY KEY(h);
CREATE TABLE table_name20160927103238_trash(
miji VARCHAR2(100) NOT NULL UNIQUE,
bumen VARCHAR2(100) NOT NULL UNIQUE,
h VARCHAR2(100) DEFAULT 'j7j' NOT NULL UNIQUE,
juj NUMBER(22) NOT NULL,
id VARCHAR2(40) NOT NULL);
COMMENT ON table table_name20160927103238_trash IS '文件j7备份表';
COMMENT ON COLUMN table_name20160927103238_trash.miji IS '密级';
COMMENT ON COLUMN table_name20160927103238_trash.bumen IS '部门';
COMMENT ON COLUMN table_name20160927103238_trash.h IS 'jj7j';
COMMENT ON COLUMN table_name20160927103238_trash.juj IS 'jjj';
COMMENT ON COLUMN table_name20160927103238_trash.id IS 'id';
CREATE INDEX jjjj ON table_name20160927103238_trash(juj);
ALTER TABLE table_name20160927103238_trash ADD PRIMARY KEY(id);
报错:
两张表有相同的索引名,报错,修改其中一个,则可以建表
CREATE INDEX jjjj ON table_name20160927103238(juj);
CREATE INDEX jjjj1 ON table_name20160927103238_trash(juj);
查询数据库中的索引:
查询数据字典user_indexes和user_ind_columns
例子:
SQL> SELECT ic.index_name, ic.column_name,
ic.column_position col_pos,ix.uniqueness
FROM user_indexes ix, user_ind_columns ic
WHERE ic.index_name = ix.index_name
AND ic.table_name = ‘S_EMP’;
注意: 数据字典里存放的字符都是大写的.