/*
说明:若已经存在相应的用户和表空间,则需要先删除相应的用户和表空间
然后再全部重新建立
*/
--删除用户
drop user plat_demo cascade;
--删除表空间
drop tablespace DATA_TEMP including contents and datafiles;
drop tablespace DATA including contents and datafiles;
--创建临时表空间
create temporary tablespace DATA_TEMP tempfile 'DATA_TEMP.DBF'
size 500M autoextend on;
--创建表空间
create tablespace DATA logging datafile 'DATA.DBF'
size 500M autoextend on;
--创建用户并指定表空间
create user plat_demo
identified by plat_demo
default tablespace DATA
temporary tablespace DATA_TEMP
profile default;
--给用户授予角色权限
grant connect to plat_demo;
grant resource to plat_demo;
grant dba to plat_demo;
--给用户授予系统权限
grant unlimited tablespace to plat_demo;
--创建自增序列sequence
create sequence SEQ_ARTICLE
minvalue 1
maxvalue 999999999999
start with 1000
increment by 1
nocache;
--添加字段:
alter table t_ta_market_info_wl add nav_show varchar2(20) default '0' not null;
--删除字段:
alter table t_ta_market_info_wl drop column nav_show;
--将有数据的表修改字段类型解决方法
1.查询表t_publish_log(目标:想把description字段的类型改成clob)
select * from t_publish_log ;
2.给表t_publish_log新增一个字段description2(目的:用来暂时存放description字段里的数据)
alter table t_publish_log
add description2 clob ;
3.将description字段里的数据复制到description2字段
update t_publish_log t set t.description2 = t.description ;
4.删除原来的description字段
alter table t_publish_log
drop column description;
5.将description2重命名为description
alter table t_publish_log
rename column description2 to description ;