oracle右连接一个常量,无

1,连接数据库;

connect scott/123456;

断开数据库

disconn;

2,查看表结构

describe scott.emp;

3,查看数据表

select empno,job,mgr,sal;

4,将缓冲区中的sql语句保存到文件

save scott_emp_query.sql

5,将文件内容读入到缓冲区中

get scott_emp_query.sql list

6,使用start命令读取并运行sql文件

start scott_emp_query.sql

7,将缓冲区内容复制到名为afiedt.buf文件(这个是默认文件)中

edit

8,将输出结果保存到指定文件中

spool scott_emp_outcome.txt append

9,带变量的语句&

select empno,ename,mgr,sal,deptno

from scott.emp

where empno >=&temp;

10,带两个变量的语句(两次输入)

select &column_name,deptno

from scott.emp

where &column_name>=7850;

11,带两个变量的语句(一次输入)

select &&column_name ,deptno

from scott.emp

where &&column_name>=7850;

12,不显示“原值”和“新值”信息

set veryify off;(on是显示)

新招:反斜杠 "/" 再次运行上面的查询

13,设置变量定义字符

set define '@'(设置以后定义变量的字符就变为@,&无效)

14,执行sql文件的语句

@ E:\TEMP\temp.sql (此处应当注意,路径是区分大小写的)

15,使用define查看常量

define;

16,设置常量

define temp=7850

查看常量

define temp

删除常量

undefine temp

17,

18,使用column设置输出格式

column empno heading '员工编号' format 9999

column ename heading '员工姓名' format a10

column mgr heading '上级编号' format 9999

column hiredate heading '受雇日期' justfify center

column sal heading '员工工资' format $999,999.99

select empno,ename,mgr,hiredate,sal

from scott.emp;

19,设置一页显示多少行数据

set pagesize 20

20,设置一行显示多少字符

set linesize 20

21,设置页眉页脚

ttitle页眉,btitle页脚

22,break命令用来分组,compute命令用来计算和

break on deptno;

compute sum of sal on deptno;

select empno,ename,mgr,sal,deptno

from scott.emp order by deptno;

23,清除column格式

clear columns

第四章

1,创建永久性表空间

create tablespace myspace

datafile '文件路径'

size 文件大小

autoextend on next 自动增加大小

maxsize 文件最大值

语法说明:

1,temporary|undo(创建撤销表空间)

2,teblespace_name

3,datafile|tempfile'file_name'

4,size

5,reuse 若存在,则删掉并重新创建

6,autoextend off|on

7,next number 自动扩展的大小

8,maxsize unlimited|number 指定数据文件最大大小

9,mininum extent number 盘区可以分配到的最小尺寸

10,blocksize number 设置数据块大小

11,online|offline

12,logging|nologging

13,force logging 强制表空间数据库对象任何操作都产生日志,否定12

14,default storage storage 指定保存在表空间中的数据库对象默认存储参数

15,compress|nocompress 是否压缩数据(消除列中的重复值)

16,permanent|temporary 指定表空间中数据的保存形式

17,extent management dictionary(数据字典形式管理) |local(本地化形式管理)

18,autoallocate|uniform size number 右边为指定表中盘区大小

19,segment space management auto |manual 指定表空间中段的管理方式

2,查看表空间属性

select * from dba_tablespace where tablespace_name='表空间名';

3,修改表空间状态

alter tablespace 表空间名 表空间状态;

4,修改表空间名字

alter tablespace 表空间名1 rename to 表空间名2;

5,利用数据字典查看空闲空间信息

select * from dba_free_space where tablespace_name ='表空间名称';

6,利用数据字典查看表空间数据文件信息

select * from dba_data_files where tablespace_name='表空间名称';

7,修改表空间对应的数据文件大小

alter database

datafile '表空间文件路径名称'

resize 大小

8,为表空间增加新的数据文件

alter tablespace myspace

add datafile '数据文件路径名称'

size 大小

autoextend on next 自增大小 maxsize 最大值;

9,删除myspace表空间数据文件

alter tablespace myspace

drop datafile '数据文件名称';

10,修改myspace表空间中数据文件的自动扩展性

alter database

datafile '表空间文件路径名称'

autoextend off;

11,设置表空间文件状态为offline drop

alter database

datafile '表空间路径名称'

offline drop;

12,移动表空间中的数据文件

(1)alter tablespace 表空间名称 offline;先设置表空间状态为offline

(2)手动操作,将磁盘中的表空间数据文件移动到新的路径

(3)使用alter tablespace语句修改表空间文件路径名称

alter tablespace myspace

rename datafile '表空间路径名称'

to

'新的表空间路径名称';

(4)修改myspace表空间状态

alter tablespace 表空间名称 online;

13,删除表空间

drop tablespace 表空间名称

including contents and datafiles;

14,创建临时表空间

create temporary tablespace 表空间名称

tempfile '表空间路径名称'

size 大小

autoextend on next 自增大小 maxsize 最大大小;

15,用数据字典查看表空间,上边有,不解释

临时表空间组不用创建,在创建临时表空间的时候直接指定即可

16, 创建临时表空间,将所在组指定为group1

create temporary tablespace 表空间名称

tempfile '表空间路径名称'

size 大小

tablespace group group1;

17,用数据字典查看表空间组信息,不解释

18,修改临时表空间组

alter tablespace 临时表空间名称 tablespace group group2;

19,创建大文件表空间

create bigfile tabliespace mybigspace

datafile '表空间路径名称'

size 大小;

20,通过数据字典查看表空间类型,不解释

21,不懂

22,修改默认表空间

alter database default tablespace 表空间名称;

23,select

第十一章

1,创建事物级临时表

create global temporary table temp_student(

)on commit delete rows(事物级别的意思);

2,使用事物级别临时表

select * from temp_student;

commit;提交事物。

提交后表还在,但数据被清除

3,创建会话临时表

create global temporary table temp_book(

)on commit preserve rows(会话级别的意思);

commit;

断开该用户连接才会清除数据

4,插入数据,一样用,不解释

5,删除临时表,一样用,不解释

6,读取外部文件

首先要在对应路径下有文件

然后 create directory external_card as 'E:\external';

创建对应路径

接下来就是创建外部表

create table e_card(

对应的数据

)organization external(

//里边这一团是什么东西噢

type oracle_loader //指定访问外部数据文件的驱动程序,oracle默认为oracle_loader

default directory external_card //对应上一步路径

access parameters(

fields terminated by ',')

location ('card.txt')

);

7,reject limit句子的使用

外部表易出错,用这个就允许有无数个错误

create table e_card(

对应的数据

)organization external(

type oracle_loader

default directory external_card

access parameters(

fields terminated by ',')

location ('card.txt')

)reject limit unlimited;

8,将错误数据存储到指定文件

create table e_card(

对应的数据

)organization external(

type oracle_loader

default directory external_card

access parameters(

records delimited by newline

badfile 'card_bad.txt'

fields terminated by ',')

location ('card.txt')

);

9,错误信息日志文件

create table e_card(

对应的数据

)organization external(

type oracle_loader

default directory external_card

access parameters(

records delimited by newline

badfile 'card_bad.txt'

logfile 'card_log.txt'

fields terminated by ',')

location ('card.txt')

);

10,创建范围分区表

create table part_book(

数据库内容

)partition by range(booktime)(

partition part1 values less than ('01-1月-2008')tablespace mytemp1,

partition part2 values less than ('01-1月-2009')tablespace mytemp2,

partition part1 values less than (maxvalue)tablespace mytemp3

)

11,创建散列分区表

create table part_book(

数据库内容

)partition by hash(bid)(

partition part1 tablespace mytemp1,

partition part2 tablespace mytemp2,

)

12,创建列表分区表

create table part_book(

数据库内容

)partition by list(bookpress)(

partition part1 values ('清华大学出版社') tablespace mytemp1,

partition part1 values ('岭南师范出版社') tablespace mytemp2

)

13,创建组合范围散列分区表

create table part_book(

数据库内容

)partition by range(booktime)

subpartition by hash(bid)

subpartitions 2 store in(mytemp1,mytemp2)

(

partition part1 values less than ('01-1月-2008'),

partition part1 values less than ('01-1月-2009'),

partition part1 values less than (maxvalue)

);

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值