有一个表sanny_goods,
通过developer的“输出数据库对象”功能可以得到如下脚本
[code="sql"]create table SANNY_GOODS
(
CODE VARCHAR2(100),
NAME VARCHAR2(100),
PRICE BINARY_DOUBLE,
TOTAL NUMBER
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
comment on table SANNY_GOODS
is '商品表';
comment on column SANNY_GOODS.CODE
is '商品编码';
comment on column SANNY_GOODS.NAME
is '商品名称';
comment on column SANNY_GOODS.PRICE
is '商品价格';
comment on column SANNY_GOODS.TOTAL
is '商品库存';
alter table SANNY_GOODS
add constraint PK_SANNYGOODS_CODE primary key (CODE)
using index
tablespace SANNY_INDEX
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table SANNY_GOODS
add constraint NN_SANNYGOODS_CODE
check ("CODE" IS NOT NULL);
[/code]
但是我想通过java程序输出这样的sql脚本,大家觉得可以实现吗,?可以怎么样写sql语句来实现,麻烦大家了:
[code="sql"]create table sanny_goods(
code varchar2(100) constraint NN_sannygoods_code not null,
name varchar2(100),
price binary_double,
total number,
constraint PK_SANNYGOODS_CODE primary key(code) using index tablespace sanny_index
);
comment on table sanny_goods is '商品表';
comment on column sanny_goods.code is '商品编码';
comment on column sanny_goods.name is '商品名称';
comment on column sanny_goods.price is '商品价格';
comment on column sanny_goods.total is '商品库存';
[/code]
[b]问题补充:[/b]
lovewhzlq,你好,
就是通过java+ibatis,运行程序手动输入表名,
运行就会自动生成一个sql文件,里面即为我需要的标准的脚本。
主要是现在sql查询有几个地方还没有解决,如何查出这个表的哪一个字段是主键,主键名,及其所用的表空间;
还有外键,呵呵