将oracle的create语句更改为alter语句使用
程序员文章站
2023-12-03 17:38:16
看pd中,双击某个表,查看其preview标签,然后会发现有某个表的create语句,如下: 复制代码 代码如下: create table company_info (...
看pd中,双击某个表,查看其preview标签,然后会发现有某个表的create语句,如下:
create table company_info (
company_id nvarchar2(50) not null,
area_id nvarchar2(50),
mem_id nvarchar2(50),
level_id nvarchar2(50),
name nvarchar2(50) not null,
capital nvarchar2(50),
unit_property number(2) not null,
economics_type number(2) not null,
man_scale number(10,0),
license_code nvarchar2(50),
license_img nvarchar2(50),
intro nvarchar2(3000),
company_img nvarchar2(200),
address nvarchar2(200),
postal_code nvarchar2(50),
tel nvarchar2(50),
fax nvarchar2(50),
mobile nvarchar2(50) not null,
email nvarchar2(50) not null,
contactor_sex number(2),
contactor nvarchar2(50),
web_site nvarchar2(200),
view_count number(20,0),
create_date date not null,
update_date date not null,
status number(2),
company_type number(2),
remain_point number(6,0),
cmp_level nvarchar2(50),
isadv number(2),
expri_date date,
display_index number(6,0),
constraint pk_company_info primary key (company_id)
);
我们如果加了某些字段,又要在原数据库上加上这些字段,我们可以这样:把create变为alter,然后将不要的
字段去除,如下所示:
alter table company_info add(
remain_point number(6,0),
cmp_level nvarchar2(50),
isadv number(2),
expri_date date,
display_index number(6,0)
)
这样就加快了我们的开发效率.
复制代码 代码如下:
create table company_info (
company_id nvarchar2(50) not null,
area_id nvarchar2(50),
mem_id nvarchar2(50),
level_id nvarchar2(50),
name nvarchar2(50) not null,
capital nvarchar2(50),
unit_property number(2) not null,
economics_type number(2) not null,
man_scale number(10,0),
license_code nvarchar2(50),
license_img nvarchar2(50),
intro nvarchar2(3000),
company_img nvarchar2(200),
address nvarchar2(200),
postal_code nvarchar2(50),
tel nvarchar2(50),
fax nvarchar2(50),
mobile nvarchar2(50) not null,
email nvarchar2(50) not null,
contactor_sex number(2),
contactor nvarchar2(50),
web_site nvarchar2(200),
view_count number(20,0),
create_date date not null,
update_date date not null,
status number(2),
company_type number(2),
remain_point number(6,0),
cmp_level nvarchar2(50),
isadv number(2),
expri_date date,
display_index number(6,0),
constraint pk_company_info primary key (company_id)
);
我们如果加了某些字段,又要在原数据库上加上这些字段,我们可以这样:把create变为alter,然后将不要的
字段去除,如下所示:
复制代码 代码如下:
alter table company_info add(
remain_point number(6,0),
cmp_level nvarchar2(50),
isadv number(2),
expri_date date,
display_index number(6,0)
)
这样就加快了我们的开发效率.