orcale 下创建 表空间和用户

来源:互联网 发布:佰迪欧百信渔具淘宝店 编辑:程序博客网 时间:2024/05/16 23:37
在向导下 建立数据库
  sqlplus "/as sysdba" 以管理员登陆
sqlplus下
-- 用system用户登录
sqlplus system/oracle@orcl
-- 创建表空间
create tablespace longs datafile 'E:\orcaleInstall\product\11.2.0\dbhome_1\JackieZhang_orcl\long.dbf' size 100M autoextend on;
--创建用户hll 密码hll
create user hll identified by hll default tablespace longs;


alert user hll identified by 123456;//修改密码
--授权
grant dba to hll;


权限设置、
grant dba to lxg;--授予DBA权限  
 grant unlimited tablespace to lxg;--授予不限制的表空间  
grant select on tablename to zhangsan;//授予zhangsan用户查看指定表的权限

grant drop on tablename to zhangsan;//授予删除表的权限

grant insert on tablename to zhangsan;//授予插入的权限

grant update on tablename to zhangsan;//授予修改表的权限

grant insert(id) on tablename to zhangsan;

grant update(id) on tablename to zhangsan;//授予对指定表特定字段的插入和修改权限,注意,只能是insert和update

grant alert all table to zhangsan;//授予zhangsan用户alert任意表的权限


  角色
角色即权限的集合,可以把一个角色授予给用户

create role myrole;//创建角色

grant create session to myrole;//将创建session的权限授予myrole

grant myrole to zhangsan;//授予zhangsan用户myrole的角色

drop role myrole;删除角色


-- 退出用hll用户登录
sqlplus hll/hll@orcl
创建表。
 
请按上面的步骤操作。
 
注意Oracle的一些基本概念。
表空间:是一个逻辑的概念,是属于所有用户共享的。
表:是属于创建他的用户的。
 
 
--查看表空间
select * from dba_tablespaces ;
--查看用户下的表:
select * from user_tables;
--查字段数:
select count(1) from user_tab_cols where table_name = 'HELP'
 
select count(*) from help;
select count(1) from help;
 
--修改表的某一列名字
alter table test rename column DEPT to DEPT_OLD; 
 
--往表中增加新的一列
alter table tb3 add AGE number;
 
 
select * from v$database;--看数据库名称
select * from v$instance;--看数据库名称
select name from v$database;
select instance_name from v$instance; 
 
 
select name from v$controlfile;
 


D:\oracle\product\10.2.0\oradata
 
 
=====================================================
备份导出:
D:\oracle\product\10.2.0\db_1\BIN>exp hll/hll@orcl file=C:\hll.dmp;
 
导入
D:\oracle\product\10.2.0\db_1\BIN>imp hll1/hll1@orcl  file= C:\hll.dmp;
 
 
报异常
Import: Release 10.2.0.1.0 - Production on 星期五 12月 9 10:20:31 2011
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
 
连接到: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
 
经由常规路径由 EXPORT:V10.02.01 创建的导出文件
 
警告: 这些对象由 HLL 导出, 而不是当前用户
 
已经完成 ZHS16GBK 字符集和 AL16UTF16 NCHAR 字符集中的导入
IMP-00031: 必须指定 FULL=Y 或提供 FROMUSER/TOUSER 或 TABLES 参数
IMP-00000: 未成功终止导入
 
 
oracle dmp 要求是低版本导出,高版本导入
 
 
导入语句 dmp后要有 分号。
D:\oracle\product\10.2.0\db_1\BIN>imp hll/hll@orcl file= C:\hll.dmp; full=y;
 
 
==========================================================
Plsql下tools下导入.dmp文件,
 Import Tables
  
 
导出成.dmp
 Export tables
  


 
导进.sql文件
 
Tools
Import Tables
SQL Inserts下
 
 
 
http://blog.sina.com.cn/s/blog_5892bb180100vjo2.html
 
原创粉丝点击