数据库表的建立、修改、删除
CREATE TABLE LYLF615."ot_test"
( "id" INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY ( START WITH 1, INCREMENT BY 1, NO CYCLE, CACHE 20 ),
"name" VARCHAR(10)
PRIMARY KEY ("id")
)
IN "mytesttbs"
INDEX IN "mytesttbs"
;
ALTER TABLE LYLF615."ot_test" DATA CAPTURE NONE;
ALTER TABLE LYLF615."ot_test" NOT VOLATILE;
ALTER TABLE LYLF615."ot_test" APPEND OFF;
ALTER TABLE LYLF615."ot_test" LOCKSIZE ROW;
ALTER TABLE LYLF615."ot_test" ADD PRIMARY KEY ("id");
ALTER TABLE LYLF615."ot_test" ADD "org_id" INTEGER;
10. 数据库表字段的定义
CREATE TABLE ot_test_org
(
org_id INTEGER not null,
org_name VARCHAR(10),
PRIMARY KEY (org_id)
)
IN "mytesttbs"
;
11. 索引、主外键的建立、修改、删除
ALTER TABLE LYLF615."ot_test" ADD CONSTRAINT FK_ORG_ID
FOREIGN KEY ("org_id")
REFERENCES LYLF615.OT_TEST_ORG (ORG_ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
;
ALTER TABLE LYLF615."ot_test" DROP CONSTRAINT FK_ORG_ID;
ALTER TABLE LYLF615."ot_test" ADD CONSTRAINT FK_ORG_ID
FOREIGN KEY ("org_id")
REFERENCES LYLF615.OT_TEST_ORG (ORG_ID)
ON DELETE NO ACTION
ON UPDATE NO ACTION
;
CREATE INDEX ON
UNIQUE INDEX ON EMPLOYEE (EMPNO) INCLUDE (LASTNAME,FIRSTNAME)create unique index newindx on newtable(no) include (value);
describe indexes for table newtable show detail;
drop index newindx
12. 视图的建立、修改、删除
CREATE VIEW LYLF615."ot_test_view" AS SELECT * FROM OT_TEST_ORG WHERE org_id=1
CREATE VIEW LYLF615."test_view1" AS
SELECT id,cname,a.org_id,b.org_name
FROM ot_test a, ot_test_org b
WHERE a.org_id=b.org_id
视图唯一能修改的是引用类型列,改变列的范围。其他定义好了都不能修改。当视图基于的基表drop后,视图变为无效。
URL:http://mycopy.blog.sohu.com/89997930.html