1. Query the database version
select * from v$version;
2. View authorization information
select * from v$license;
3. View Dameng database name
select name,create_time from v$database;
4. Check whether the case configuration is sensitive
--Size sensitive (1 is case sensitive, 0 is case insensitive)
SELECT SF_GET_CASE_SENSITIVE_FLAG();
或
SELECT CASE_SENSITIVE()
5. Query the maximum connection of the database
select SF_GET_PARA_VALUE(2,'MAX_SESSIONS');
6. Check the current status of Dameng database
select status$ from v$instance;
7. Check the authorization expiration date
select EXPIRED_DATE from v$license;
8. Query the location of data files
select GROUP_ID , ID ,path,STATUS$ from v$datafile;
9. Query table space size
select FILE_NAME,FILE_ID,TABLESPACE_NAME,BYTES/1024/1024||'M' from dba_data_files;
10. Query table space usage
select t1.NAME tablespace_name,
t2.FREE_SIZE*SF_GET_PAGE_SIZE()/1024/1024 ||'M' free_space,
t2.TOTAL_SIZE*SF_GET_PAGE_SIZE()/1024/1024 ||'M' total_space,
t2.FREE_SIZE*100/t2.total_size "% FREE"
from V$TABLESPACE t1, V$DATAFILE t2
where t1.ID=t2.GROUP_ID;
11. Query all SCHEMA
select * from dba_objects where object_type='SCH';
12. Query all users
select username from dba_users;
13. Switch SCHEMA
set schema "testSchema";
14. Create SCHEMA
CREATE SCHEMA "testSchema";
15. Full table name in query mode
select TABLE_NAME from all_tables WHERE OWNER='testSchema';
16. Delete SCHEMA
drop schema "testSchema";
17. Column comments
COMMENT ON COLUMN testSchema.peoples.role_id is '角色Id';
18. Query column comments
select * from SYSCOLUMNCOMMENTS
where SCHNAME='testSchema' and TVNAME='peoples' and COLNAME='role_id';
19. Table comments
comment on table testSchema.peoples is '这是一个表注释';
20. Query table comments
select * from SYSTABLECOMMENTS where SCHNAME='testSchema' and TVNAME='peoples';
21. Create table space
CREATE TABLESPACE MANAGEMENT DATAFILE 'MANAGEMENT.DBF' SIZE 128;
22. View table space
select * from dba_data_files;
select * from dba_tablespaces;
select * from v$tablespace;
23. Create user
CREATE USER testUser IDENTIFIED BY "testUsersPwd" DEFAULT TABLESPACE MANAGEMENT;
GRANT DBA TO testSchema;
24. Check the number of connections of the current instance
select clnt_ip,user_name,state,count(*) from v$sessions group by clnt_ip,user_name,state;