1、使用超级用户登录sqlplus。
2、创建表空间:
SQL> create tablespace test
2 datafile 'D:\oracle\oradata\test\test.dbf'
3 size 100M autoextend on next 10M maxsize unlimited extent management local;
3、创建用户和密码:
SQL> create user Username identified by Password default table
2 users Temporary TABLESPACE Temp;
4、用户受权限:
SQL> grant connect,resource,dba to Username;
5、提交:
SQL> commit;
、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、
如果在清除表空间之前,先删除了表空间对应的数据文件,会造成数据库无法正常启动和关闭。
可使用如下方法恢复(此方法已经在oracle9i中验证通过):
下面的过程中,filename是已经被删除的数据文件,如果有多个,则需要多次执行;tablespace_name是相应的表空间的名称。
$ sqlplus /nolog
SQL> conn / as sysdba;
如果数据库已经启动,则需要先执行下面这行:
SQL> shutdown abort
SQL> startup mount
SQL> alter database datafile 'filename' offline drop;
SQL> alter database open;
SQL> drop tablespace tablespace_name including contents;
导入导出命令:
创建用户
-- Create the user
create user JXTELE_HOMS
identified by "123456"
default tablespace HOMS
temporary tablespace TEMP
profile DEFAULT;
-- Grant/Revoke role privileges
grant connect to JXTELE_HOMS with admin option;
grant dba to JXTELE_HOMS with admin option;
grant resource to JXTELE_HOMS with admin option;
-- Grant/Revoke system privileges
grant unlimited tablespace to JXTELE_HOMS with admin option;
创建视图
create or replace view inpass_encape_byid as
select p.*,e.ESCAPECODE ,e.ESCAPE_NAME ,e.ESCAPE_SEX ,e.ESCAPE_BIRTHDAY,e.ESCAPE_IDCARD ,e.ESCAPE_AREA ,
e.ESCAPE_ADDRESS ,e.REASON ,e.WATCHTIME ,
e.WATCHUNIT ,e.SIGN ,e.AGE ,e.CALLPHONE ,e.CALLTELEPHONE ,e.WATCHUNITCODE ,h.hotelname
from in_passenger p join escape e on p.cardcode=e.escape_idcard join hotel h on p.hotelcode=h.hotelcode;
create or replace view in_out_passstatic as
select code,name,count(pcode) cnt,intime,decode(a.roomcount,null,'0',a.roomcount) roomcount
from (select h.hotelcode code,h.hotelname name,substr(i.in_datetime,0,8) intime,i.in_passengercode pcode,h.roomcount roomcount
from IN_Passenger i right join Hotel h on i.hotelcode=h.hotelcode
group by h.HotelCode,substr(i.in_datetime,0,8),h.hotelname,i.in_passengercode,h.roomcount
union select t.hotelcode code,t.hotelname name,substr(p.in_datetime,0,8) intime,p.out_passengercode pcode,t.roomcount roomcount
from Out_Passenger p right join Hotel t on p.hotelcode=t.hotelcode
group by t.HotelCode,substr(p.in_datetime,0,8),t.hotelname,p.out_passengercode,t.roomcount ) a
group by a.code,a.intime,a.name,a.roomcount order by a.code;
create or replace view in_passstatic as
select code,name,count(pcode) cnt,intime,decode(a.roomcount,null,'0',a.roomcount) roomcount
from (select h.hotelcode code,h.hotelname name,substr(i.in_datetime,0,8) intime,i.in_passengercode pcode,h.roomcount
from IN_Passenger i right join Hotel h on i.hotelcode=h.hotelcode
group by h.HotelCode,substr(i.in_datetime,0,8),h.hotelname,i.in_passengercode,h.roomcount) a
group by a.code,a.intime,a.name,a.roomcount order by a.code;
create or replace view out_passstatic as
select code,name,count(pcode) cnt,intime,decode(a.roomcount,null,'0',a.roomcount) roomcount
from (select t.hotelcode code,t.hotelname name,substr(p.in_datetime,0,8) intime,p.out_passengercode pcode,t.roomcount
from Out_Passenger p right join Hotel t on p.hotelcode=t.hotelcode
group by t.HotelCode,substr(p.in_datetime,0,8),t.hotelname,p.out_passengercode,t.roomcount ) a
group by a.code,a.intime,a.name,a.roomcount order by a.code;