一:前言

  每次我自己来导出oracle数据的数据进行备份的时候都是要看一遍记载的语句,还别说自己敲多了,也熟练了,但是还是不是很放心,所以就记载下来吧。

二:内容

  (1)、最简单,最直接的导入方式(这种导入需要用户具有dba权限)

imp user/password file="H:/db_table.dmp" full=y

  (2)、导出数据库的方式

  A:最简单最直接的方式

    

exp user/password @192.168.22.22/orcl file=F:/db_table.dmp

  B:指定需要导出的表(因为有的表的数据很多,所以可以有选择的导数据)

exp user/password@192.168.22.22/orcl file=F:/db_table.dmp tables=(table1,table2,table3,table4,table5,table6,table7,table8,table9,table10)

对于B的说明,file那里也可以写成这样“file=./db_table.dmp”

  c:导出表的结构

  

exp user/password@192.168.22.22/orcl file=filename.dmp rows=N;

  D:导出表的空间:

  

导出指定表空间
exp user/password@192.168.22.22/orcl transport_tablespace=y tablespaces=(table_space_name) file=filename.dmp

  (三):修改表结构

  增加一个字段

alter table db_table add  creator varchar(20);
comment on column db_table .creator is '创建人';##增加注解

  修改某个字段的类型

##修改某个字段名称
alter table db_table rename column sname to name;
##修改某个字段类型
alter table db_table modify createtime Date;

  (四):查询一些表或者数据库的属性

  查看表名和object_id

  

select object_name, object_id from user_objects where object_name = 'db_name';

 

   查询表的结构

select * from user_tab_columns where Table_Name='db_table'; 

  

  一张表的列名,数据类型,数据长度

  

select column_name,data_type,data_length,DATA_PRECISION ,DATA_SCALE
from all_tab_columns where table_name='db_table';

  

  查看表的注解

select * from user_tab_comments;

  

  查看表中列的注解

  

select * from user_col_comments where table_name='db_table'

  

  查看表的属性,表的所属者

  

select * from dba_tab_columns where table_name='db_table'

  

  查看表的属性空间

  

select * from dba_tables where table_name='db_table';

  (五):创建最简单索引(创建索引就是创建目录,已经排好序,所以调用所以来查找时就会按照这个排序来找)

  

 create index  index_yz_db_column on db(column);

  

  (六):锁

  查询锁

##查询锁
select * from v$session a ,v$locked_object b where a.sid=b.session_id; select sess.sid,
sess.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name,
lo.locked_mode
from v$locked_object lo,
dba_objects ao,
v$session sess
where ao.object_id=lo.object_id and lo.session_id=sess.sid;

  解除锁

##解除锁
alter system kill session='430,14747'

(7)创建表空间

  

#创建表空间
create tablespace PRISON_DATA_SPACE
datafile 'H:\oracle_table_space\table_DATA_SPACE.dbf'
size 50m
autoextend on
next 10m #每次增加100m
extent management local;

(8)给用户赋权限

  

用户的权限赋值:
-- Create the user
create user SCOTT
default tablespace USERS
temporary tablespace TEMP
profile DEFAULT
password expire;
-- Grant/Revoke role privileges
grant connect to SCOTT;
grant dba to SCOTT;
grant resource to SCOTT;
-- Grant/Revoke system privileges
grant unlimited tablespace to SCOTT;

(8)拼凑sql

select 'create  or replace  view as select '|| wm_concat(column_name) || 'from 表2' from user_tab_columns
where table_name='表1';

 删除数据库中的所有表

select 'drop table '|| table_name from user_tables;

oracle数据库cmd导出数据和导入数据的更多相关文章

  1. sqlloader导出数据和导入数据

    分类: Oracle 忙了一天终于把sqlloader导出数据和导入数据弄清楚了,累死俺了... 这个总结主要分为三个大部分,第一部分(实例,主要分两步),第二部分(参数小总结),第三部分(完全参数总 ...

  2. oracle中使用impdp数据泵导入数据提示“ORA-31684:对象类型已经存在”错误的解决

    转载请注明出处:http://blog.csdn.net/dongdong9223/article/details/47448751 本文出自[我是干勾鱼的博客] oracle中使用impdp数据泵导 ...

  3. mysql数据库迁移到oracle数据库后 如何删除相同的数据

    mysql数据库迁移到oracle数据库后 如何删除相同的数据 首先搞清楚有多少数据是重复的 select pid from product group by pid having count(pid ...

  4. Oracle 数据库表中已有重复数据添加唯一键(唯一约束)

    Oracle 数据库表中已有重复数据添加唯一键(唯一约束) 问题描述 以 demo 举例,模拟真实场景. 表 TEST_TABLE 有如下字段和数据:id 是主键,code 没有设置键和索引 ID C ...

  5. oracle在cmd下通过命令导入导出数据

    1.首先在cmd下切换到oracle的客户端的exp.exe所在的bin目录下,例如 D:\oracle\product\10.2.0\client_2\BIN 数据导出:导出的数据库名称是在tnsn ...

  6. [CMD]oracle数据库的导出导入

    除了推荐使用PL/SQL Developer 工具对oracle进行导出导入(http://www.cnblogs.com/whylaughing/p/5983490.html )之外,比较常用的还有 ...

  7. oracle 数据库Cmd命令导入导出

    imp 导入数据库:       1.直接导入数据表:   imp username/passwork@orcl file=d:/AA.dmp          eg: imp 用户名/密码@orcl ...

  8. oracle 导出数据和导入数据

    导出数据 exp zl_gj/zlkj@gqxt  grants=y tables=(zl_gj.ckgj,zl_gj.gjlx,zl_gj.rkgj) file=c:\gj.dmp log=c:\g ...

  9. PL SQL Developer 13连接Oracle数据库并导出数据

    下载 并安装 PL SQL Developer 13,默认支持中文语言 ============================= 注册码: product code: 4vkjwhfeh3ufnqn ...

随机推荐

  1. safari 移动下开启 滚定回弹

    -webkit-overflow-scrolling : touch;

  2. Spotlight on MySQL

    聚光灯在MySQL 1.Sessios会话Total Users:总用户数前连接到MySQL服务器的用户会话总数Active Users:活跃用户此控件表示连接到当前正在执行SQL语句或其他数据库请求 ...

  3. LAMP架构应用实战—Apache服务介绍与安装01

    LAMP架构应用实战—Apache服务介绍与安装01   一:Apache是什么 Apache是Apache基金会开发的一个高性能.功能强大.安全可靠.灵活的开放源码的WEB服务软件 二:Apache ...

  4. HDU 4744 Starloop System(最小费用最大流)(2013 ACM/ICPC Asia Regional Hangzhou Online)

    Description At the end of the 200013 th year of the Galaxy era, the war between Carbon-based lives a ...

  5. 数论3——gcd&&lcm

    gcd(a, b),就是求a和b的最大公约数 lcm(a, b),就是求a和b的最小公倍数 然后有个公式 a*b = gcd * lcm     ( gcd就是gcd(a, b), ( •̀∀•́ ) ...

  6. centos tomcat开机自启

    在 /etc/rc.local 下 输入tomcat bin目录下的startup.sh  /usr/tomcat8/bin/startup.sh 即可

  7. c++ 中反正单词用到了resize()

    resize(n) 调整容器的长度大小,使其能容纳n个元素.如果n小于容器的当前的size,则删除多出来的元素.否则,添加采用值初始化的元素. 题目如下: 151. Reverse Words in ...

  8. maven release版本重复上传error

    A couple things I can think of: user credentials are wrong url to server is wrong user does not have ...

  9. 【Python】Python中子类怎样调用父类方法

    python中类的初始化方法是__init__(),因此父类子类的初始化方法都是这个,如果子类不实现这个函数,初始化时调用父类的初始化函数,如果子类实现这个函数,就覆盖了父类的这个函数,既然继承父类, ...

  10. Win10上部署Apollo配置中心

    基于Docker在Win10上部署Apollo配置中心 https://www.jianshu.com/p/a1215056ce75 http://nobodyiam.com/2016/07/09/i ...