`
teachertina
  • 浏览: 11962 次
  • 性别: Icon_minigender_1
  • 来自: 湖南
社区版块
存档分类
最新评论

oracle 复习体系三 数据库操作

 
阅读更多

--oracle 复习体系三

--显示当前登录用户
show user

--查询当前方案下的所有表
select * from tab

--断开数据库连接
disconnect

--table
create table teacher (int number(3,2),username varchar2(50));

--alter table

--添加字段
alter table teacher add (password varchar(20));

--修改字段
alter table teacher modify (id number(5));

--修改字段类型,名字(不能有数据)
alter table teacher modify(id char(29));

--删除字段
alter table teacher drop column password;

--修改表明

rename teacher to xxxx;

drop table teacher;

--insert

insert into teacher (1,'xx');

--插入数据 数据来源与scott.emp(empno,ename)
conn scott/tiger

grant select on emp to tina with grant option;

conn tina/tina

insert into teacher select empno,ename from scott.emp;

select * from teacher

select * from scott.emp;
-- 查询username 为空的
select * from teacher where username is null

--不为空的
select * from teacher where username is not null;

--创建保存点
savepoint a;


drop from teacher ;

truncate table teacher;


--恢复到保存点
rollback to a;

 

 

 

 

 

 

--备份与恢复

 

 

--备份

--导出自己的表

exp userid=scott/tiger@orcl tables(emp) file=d:/emp.dmp

 

--导出其他方案的表,需要dba 的权限或者是exp_full_database

exp userid=system/manager@orcl tables(scott.emp,scott.xxx) file=d:/emp.dmp

 

--导出表结构

exp userid=scott/tiger@orcl tables(emp) file=d:emp.dmp rows=n

 

--快速使用直接导出的方式,速度快,适合大表

exp userid=scott/tiger@orcl talbes(emp,emp2,emp3) file=d:emp.dmp direct=y

--导出自己的方案

exp userid=scott/tiger@orcl owner=scott file =d:/emp.dmp

 

--导出别人的方案需要dba的权限或者exp_full_database

exp userid=system/manager@orcl owner=(system,scott,其他方案名称) file

 

--导出数据库实现增量备份

--full =y :导出所有

--inctype= complete 增量

exp userid=system/manager@orcl full =y inctype=complete file=d:/database.dmp

 

 

--导出

imp userid=scott/tiger@orcl tables=(emp) file=d:/xx.dmp

 

imp userid=scott/tiger@orcl tables=(emp) file=d:/xx.dmp touser=tina

 

imp userid=scott/tiger@orcl tables=(emp) file=d:/xx.dmp rows =n

 

imp userid=scott/tiger@orcl tables=(emp) file=d:/xx.dmp ignore=y

 

imp userid=scott/tiger file=xx.dmp

 

imp userid=system/manager fromuser=system touser=scott file=d:/xx.dmp

--导入数据库

imp userid=system/manager full =y file=d:/xx.dmp

 

 

--恢复表

 

conn scott/tiger

 

--查看该方案下的所有表

select * from tab

 

--删除表

drop table emp

 

--显示回收站,表被删除之后并没有直接删掉,在回收站中还可以看到

show recyclebin

 

--恢复 恢复到删除之前

flashback table emp to before drop

 

 

--如果想要直接删除:

--1.直接删除

drop table emp purge

--2.删除之后直接清空回收站

purge recyclebin

 

--也可以清空回收站中的指定表

purge table emp

 

--清空指定表空间

purge tablespace xxx

 

--清空指定表空间下的指定用户

 

purge tablespace xx user scott

 

分享到:
评论

相关推荐

    Oracle数据库的体系结构.pdf

    Oracle数据库的体系结构,适合期末复习使用

    大型数据库系统复习题.doc

    第三章 ORACLE 11g 的数据库管理 第四章 ORACLE 11g 的表空间管理 第五章 ORACLE 11g 的表管理 第六章 ORACLE 11g 的数据查询 第七章 ORACLE 数据的基本操作 第八章 索引 第九章 视图 第十章 PL/SQL基础 第十一章 ...

    oracle数据库基础知识(数据库程序设计)

    instance (实例)、数据文件、日志文件、参数文件、数据文件与表空间的关系 3、2是有关ORACLE的一些基本概念,下面要学习的是一些简单的的实际操作 ,就是如何去管理ORACLE数据库,当然不是管理全部的ORACLE。在此...

    oracle考试复习资料

    网上整理的一些复习题,和大家分享。 包括: 一 ORACLE系统体系结构基础知识, 二 服务器上的文件结构 三ORACLE工具SQL Plus相关 四.启动和关闭数据库 五ORACLE命令小结 等内容希望对大家有用

    数据库原理(第5版)

    第8章介绍了商业智能(BI)系统和支持它们的数据仓库体系结构,还讨论了多维数据库,解释了如何为Heather Sweeney Designs建立多维数据库,并使用它生成PivotTable OLAP报表。 附录A提供了SQL Server 2008 R2 Express...

    中博科创ORACLE培训资料.rar

    教学内容 数据库的体系结构 总结一张体系结构表,复习,考试 装数据库;通过OEM查看体系结构;掌握数据库模式与开关数据库指令 时间 第二天 备份 上午(9:00至11:00) 下午(2:00至5:30) 晚上(6...

    SQL server的sql语句知识体系框架

    对sql语句的学习,复习都有帮助。 SQL 概述 ...软件称为数据库管理系统(DBMS),全称为 DataBase Management System,如:Oracle、SQL Server、MySql、Sybase、 informix、DB2、interbase、PostgreSql 。

    leetcode中国-Kunaly-Notes:刘老shi笔记,了无生趣的生活,偷偷学点东西

    本仓库用于记录学习过程中的所思所想,并力图构建一个完善的知识体系,便于复习巩固。 :folded_hands: 由于本人水平有限,仓库中的知识点来自本人原创、视频、书籍、博客等,非原创均已标明出处(或在参考资料中列出...

    计算机实习日记

    公司的软件产品所使用的数据库各不相同,有MS SQL Server、MYSQL、ORACLE、Db2、Sybast、informix等等,我在学校里面接触的数据库软件仅仅只有MS SQL Server这一种。现在终于体会到人们在说“书到用时方恨少”这句话...

Global site tag (gtag.js) - Google Analytics