oracle 常用简单命令语句

1、建用户

create user test_user identified by test_password;

create user test_user identified by test_password default tablespace ts_zzg; //直接在建用户的时候就赋予表空间

2、建表空间

create tablespace ts_zzg datafile 'f:\ts_zzg\zzg_data.dbf' size 200M autoextend on  next 50m maxsize 20480m 

extent management local;

3、将表空间分配到用户

alter user test_user default tablespace ts_zzg;

4、用户授权

临时用户,特指不需要建表的用户,通常只赋予他们connect role.

grant create session,create table,create view,create sequence,create tablespace to test_user

grant connect,resource,dba to test_user;

回收用户权限

revoke dba from test_user;

5、创建表

 

  create table menu(
   id varchar2(64) not null,  parent_id varchar2(64) not null,  name varchar2(100) not null,  depth number(2) not null,  primary key (id)  )

6、创建只读视图

create or replace view vw_employees as 
    select employee_id, employee_name, employee_position, employee_age 
    from employees 
    with read only

7、登录用户

普通登录

conn test_user/test_password;

 

在服务器端免密码登陆oracle

在dos界面输入:sqlplus / as sysdba;

 

8、删除用户及相关对象

drop user test_user cascade;

9、数据库导入导出

exp:

  1) 将数据库orcl完全导出

    exp system/manager@orcl file=d:\orcl_bak.dmp full=y

  2) 将数据库中system用户的表导出

    exp system/manager@orcl file=d:\system_bak.dmp owner=system

  3) 将数据库中表table1,table2导出,不导出数据

    exp system/manager@orcl file=d:\table_bak.dmp tables=(table1,table2)  rows=no

  4) 将数据库中的表customer中的字段mobile以"139"开头的数据导出

    exp system/manager@orcl file=d:\mobile_bak.dmp tables=customer query=\"where mobile like '139%' \"

  imp:

  1) 将备份文件bak.dmp导入数据库

    imp system/manager@orcl file=d:\bak.dmp

    如果数据表中表已经存在,会提示错误,在后面加上ignore=y就可以了。  

  2) 将备份文件bak.dmp中的表table1导入

    imp system/manager@orcl file=d:\bak.dmp fromuser=seapark tables=(table1) 

 

10、创建dblink

  • create /* public */ database link dblink1  
  •   connect to dbusername identified by dbpassword  
  •   using '(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL = TCP)(HOST = 192.168.0.1)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = orcl)))'; 

   查询所有的dblink        select * from dba_db_links;

 

 

 

 

 

 

转载于:https://www.cnblogs.com/KQNLL/p/6374148.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值