1.了解system用户下有多少个表,每个表的作用:
select a.TABLE_NAME, b.COMMENTS,a.NUM_ROWS,a.OWNER,a.TABLESPACE_NAME
from dba_tables a, all_tab_comments b
where a.TABLE_NAME = b.table_name(+)
order by a.OWNER,a.TABLE_NAME
2.了解t_user这个表的一些相关信息:
select a.TABLE_NAME, b.COMMENTS,a.NUM_ROWS,a.OWNER,a.TABLESPACE_NAME
from dba_tables a, all_tab_comments b
where a.TABLE_NAME = b.table_name(+)
and a.TABLE_NAME='t_user'
order by a.OWNER,a.TABLE_NAME
3.如果你想查一下某个表(如:t_user)的所有字段,以及字段的说明:
select * from all_col_comments a where a.table_name='t_user'
4.给oracle数据加序列:
(select emp_sequence.nextVal from dual)
CREATE SEQUENCE emp_sequence
INCREMENT BY 1 -- 每次加几个
START WITH 1 -- 从1开始计数
NOMAXVALUE -- 不设置最大值
NOCYCLE -- 一直累加,不循环
CACHE 10;
注意事项:
1. 必须以管理员身份登录;
2. sequence_owner必须为大写,不管你的用户名是否大写。只有大写才能识别。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
--查看当前用户的所有序列
select SEQUENCE_OWNER,SEQUENCE_NAME from dba_sequences where sequence_owner=
'用户名'
;
--查询当前用户的序列总数
select count(*) from dba_sequences where sequence_owner=
'用户名'
;
--示例:
select SEQUENCE_OWNER,SEQUENCE_NAME from dba_sequences
where sequence_owner=’WGB;
select count(*) from dba_sequences where sequence_owner=’ WGB’;
SQL> select SEQUENCE_OWNER,SEQUENCE_NAME from dba_sequences
2
where sequence_owner=
'WGB'
;
SEQUENCE_OWNER SEQUENCE_NAME
------------------------------ ------------------------------
WGB SEQ_FOR_TEST
WGB SEQ_WGB_ADMIN
WGB SEQ_WGB_COMMON
WGB SEQ_WGB_COMMONS
WGB SEQ_WGB_CONTACTOR
WGB SEQ_WGB_FACES
WGB SEQ_WGB_MEMBER
WGB SEQ_WGB_MESSAGE
WGB SEQ_WGB_MONEY_USER
已选择
9
行。
SQL> select count(*) from dba_sequences where sequence_owner=
'WGB'
;
COUNT(*)
----------
9
|