oracle 常用查询命令
数据字典dict总是属于Oracle用户sys的。
1、用户:
select username from dba_users;
改口令
alter user spgroup identified by spgtest;
2、表空间:
select * from dba_data_files;
select * from dba_tablespaces;//表空间
select tablespace_name,sum(bytes), sum(blocks)
from dba_free_space group by tablespace_name;//空闲表空间
select * from dba_data_files
where tablespace_name='RBS';//表空间对应的数据文件
select * from dba_segments
where tablespace_name='INDEXS';
3、数据库对象:
select * from dba_objects;
CLUSTER、DATABASE LINK、FUNCTION、INDEX、LIBRARY、PACKAGE、PACKAGE BODY、
PROCEDURE、SEQUENCE、SYNONYM、TABLE、TRIGGER、TYPE、UNDEFINED、VIEW。
4、表:
select * from dba_tables;
analyze my_table compute statistics;->dba_tables后6列
select extent_id,bytes from dba_extents
where segment_name='CUSTOMERS' and segment_type='TABLE'
order by extent_id;//表使用的extent的信息。segment_type='ROLLBACK'查看回滚段的空间分配信息
列信息:
select distinct table_name
from user_tab_columns
where column_name='SO_TYPE_ID';
5、索引:
select * from dba_indexes;//索引,包括主键索引
select * from dba_ind_columns;//索引列
select i.index_name,i.uniqueness,c.column_name
from user_indexes i,user_ind_columns c
where i.index_name=c.index_name
and i.table_name ='ACC_NBR';//联接使用
6、序列:
select * from dba_sequences;
7、视图:
select * from dba_views;
select * from all_views;
text 可用于查询视图生成的脚本
8、聚簇:
select * from dba_clusters;
9、快照:
select * from dba_snapshots;
快照、分区应存在相应的表空间。
10、同义词:
select * from dba_synonyms
where table_owner='SPGROUP';
//if owner is PUBLIC,then the synonyms is a public synonym.
if owner is one of users,then the synonyms is a private synonym.
11、数据库链:
select * from dba_db_links;
在spbase下建数据库链
create database link dbl_spnew
connect to spnew identified by s
相关文档:
select decode('X','Q','变量1','变量2') from dual
select sysdate,to_char(sysdate,’yyyy-mm-dd hh24:mi:ss’) from dual
select to_date(’2003-10-17 21:15:37’,’yyyy-mm-dd hh24:mi:ss’) from dual
日期格式参数 含义说明
D 一周中的星期几
DAY 天的名 ......
oracle 逻辑备份命令EXP/IMP参数参考手册
帮助命令:exp help=y
Export: Release 10.2.0.1.0 - Production on Thu Jul 20 10:39:50 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
You can let Export prompt you for parameters by entering the EXP
command followed b ......
在PL/SQL程序设计中,有三种定义记录类型的方法:一种是使用%ROWTYPE属性;另一种是在PL/SQL程序的声明部分显示定义记录类型;最后一种方法是将记录类型定义为数据库结构或对象类型。
我先简单的介绍一个下面要用到的表的结构(黑体标明的字段为主键):
INDIVIDUALS表
INDIVIDUAL ID
FIRST NAME
MIDDLE_INITI ......
刚刚在inthirties老大的博客里看到这篇文章,写的不错,正好自己最近在学习PL/SQL,转过来学习学习。
==================================================================================
bulk collect是可以看做是一种批获取的方式,在我们的plsql的代码段里经常作为into的扩展来使用。对于select id into v from ... ......