基本上Oracle、SQL-Server、MDB可以通用。
■基础篇
create table cxck.t订货 (
订货号 char (15) primary key,
产品号 varchar2(18),
订货数 number (9),
客户号 char (4),
操作员 char (7),
更新日期 char (10),
更新时间 char (8)
);
■复制创建
create table cxck.t订货1 as
select * from cxck.t订货 where 订货号 = '@';
create table cxck.t订货1 as
select * from cxck.t订货;
create table cxck.t订货1 as
select 订货号, 产品号 from cxck.t订货;
** 只复制表结构和数据。
** 不复制primary key 等约束。
** 可以通过alter table 追加primary key 等约束。
** 如果只创建空表,可以指定0纪录的where 查询条件。(例如:where 订货号 = '@' )
■复合创建
create table cxck.t订货1 as
select * from cxc.t订货
where 产品号 in
(select distinct 产品号 from cxck.t产品 where 产品号 = 'a001')
union all
select * from cxck.t订货
where 产品号 in
(select distinct 产品号 from cxck.t产品 where 产品号 = 'a001')
;
** 可以用union代替union all去掉重复纪录。
■表,视图等重命名
rename cxck.t订货1 to cxck.t订货2;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/174388/viewspace-905970/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/174388/viewspace-905970/