oracle 相關的sql語句
数据字典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
相关文档:
具体步骤就不多说了 ,要导出的SQLSERVER表叫 LDJCUS,主键 Uid (int 自动增长列),导入到Oracle总报错:对象名无效 ,去掉主键列就可以,不知道为什么?难道自动增长的主键列就不能导入到Oracle中???疑惑。。。。 ......
Oracle实现自增主键
oracle没有ORACLE自增字段这样的功能,但是通过触发器(trigger)和序列(sequence)可以实现。
create table t_client (id number(4) primary key,
pid number(4) not null,
name varchar2(30) not null,
client_id varchar2(10),
client_level char(3),
bank_acct_no varchar2(30),
contact_tel&n ......
connect by 是结构化查询中用到的,其基本语法是:
select ... from tablename start with 条件1
connect by 条件2
where 条件3;
例:
select * from table
start with org_id = 'HBHqfWGWPy'
connect by prior org_id = parent_id;
简单说来是将一个树状结构存储在一张表里,比如一个表中存在两个字段:
......
工作过程中需要将oracle中的数据导入到excle中,自己做了一下,先将方法介绍如下,
你可以根据自己的实际情况,做出更改。
1,建立一个emp.sql文件我的是在F :\SQL\EMP.SQL
set line 120
set pagesize 100
set feedback off
--关闭类似于“已选11行”这样的输出反馈,以保证spool输出定义的--文件中只有我们 ......
--创建序列
create sequence innerid
minvalue 1
maxvalue 999999999
start with 1
increment by 1
cache 20
order;
--创建表
create table users(
userid int primary key,
username varchar2(20),
userpwd varchar2(20)
);
select * from users;
insert into users values( ......