Oracle数据库基本操作

--创建表空间(一个表空间可以有多个用户)--
create tablespace demo
datafile 'D:\oracle\oradata\junchen\PLATFORM\demo.dbf'
size 50m
autoextend on;

--创建用户,并且关联表空间--
create user demo
identified by dd
default tablespace demo;

--给用户分配权限--
grant connect,resource to 用户名;
grant create view to 用户名;--创建视图权限
grant create sequence to 用户名;--创建序列权限
grant sysdba to 用户名;--管理员权限

grant create session,create any table,create any view,create any index,create
any procedure,alter any table,alter any procedure,drop any table,drop any view,drop any index,drop any procedure,
select any table,insert any table,update any table,delete any table,dba to demo;--所有权限



--修改数据文件--
--查看数据文件路径--
select file_id,bytes,file_name from dba_data_files;
--重新指定尺寸为20M--
alter database datafile '数据文件路径' resize 20m;



--修改表所属表空间:
alter table 表名 move tablespace "表空间名称"

--修改表索引所属表空间:
alter index 索引名 rebuild tablespace "表空间名称"



导出数据库
exp userid=jsmall/jsmall@10.168.149.144/orcl file=e:/demo.dmp
exp userid=DD_APP/dd@10.181.203.10/prosc file=e:/DD_APP.dmp
exp userid=DD_EFLOW/dd@10.181.203.10/prosc file=e:/DD_EFLOW.dmp
exp userid=AUTH/dd@10.181.203.10/prosc file=e:/AUTH.dmp
exp userid=SB_PORTAL/dd@10.181.203.10/prosc file=e:/SB_PORTAL.dmp

导入数据库
imp system/11@prop file=f:\data.DMP full=y
解决oracle“这些对象由xxx导出,而不是当前用户”方案
imp userid=demo/dd@localhost/prosc file=E:/demo.dmp ignore=y fromuser=demo touser=demo
imp userid=DD_APP/dd@localhost/prosc file=E:/DD_APP.dmp ignore=y fromuser=DD_APP touser=DD_APP
imp userid=DD_EFLOW/dd@localhost/prosc file=E:/DD_EFLOW.dmp ignore=y fromuser=DD_EFLOW touser=DD_EFLOW
imp userid=AUTH/dd@localhost/prosc file=E:/AUTH.dmp ignore=y fromuser=AUTH touser=AUTH
imp userid=SB_PORTAL/dd@localhost/prosc file=E:/SB_PORTAL.dmp ignore=y fromuser=SB_PORTAL touser=SB_PORTAL




--删除--
--1、删除表及序列等--
--2、删除用户--
drop user 用户名;
--3、删除表空间--
drop tablespace 用户名_tablespace;

分页:
select * from (
       select row_.*, rownum rownum_ from (
              查询sql
       ) row_
) where rownum_ <= 结束行 and rownum_ > 起始行;
查询总行数:
select count(1) from (查询SQL) tmp_count;

posted @ 2015-11-02 12:44  老亮侃码  阅读(180)  评论(0编辑  收藏  举报