Dameng Common Statements

Source: Internet
Author: User

1. Querying table Space

Sql> select * from V$tablespace;

2. Mode Query

Sql> SELECT * from dba_segments;

The system view lookup, the speed is much slower (7.1.4.6 version is not supported)

Sql> SELECT object_name from all_objects where object_type = ' SCH ';

3. Enquiry Form

Sql> SELECT * from Dba_tables where tablespace_name= '%s ';   Based on the tablespace name, case sensitive
sql> select * from SYSOBJECTS where Schid = (SELECT object_id from all_objects where object_name = ' %s ' and 
     object_type = ' SCH ') and (subtype$ = ' utab ' or subtype$ = ' STAB '); 
     Based on the pattern name, the public property pattern ID is used. Utab user table, Stab system table

4. Close the database

sql> shutdown normal;

Shut down the database in the normal way

sql> shutdown immediate;

Close the database immediately. The database does not close immediately, but closes (terminates the session and frees the session resources) after some cleanup work is performed. Requires 10 to 20S

sql> shutdown abort;

Close the database directly. The session that is accessing the database is terminated abruptly, and if a large number of operations are executing in the database, it takes a long time to restart the database after shutdown abort is executed

5. User and Mode
User: Used to connect to database Access database
Schema: Schema object is the logical structure of database data
Relationship: Mode and the user in Oracle is a one-to-one relationship, DB2 a user can correspond to multiple modes, DM is a pair of many (no schema concept in MySQL)

6. Schema rules cannot have objects of the same name in the same mode, but you can specify a tablespace when the object names in different schemas can be the same when you create a new table. If not specified, the default save to main user can access other schema objects directly, but if you want to access other schema objects, you must have object permissions when the user wants to access other schema objects, the schema masterpiece suffix (schema.table) must be appended

7. Table Space
The DM tablespace mimics the table space of Oracle
Objects with the same name can exist under the same tablespace

Sql> alter tablespace "%s" offline;     Table space offline
sql> alter tablespace "%s" online;

8. Mode Switch

sql> SELECT sys_context (' Userenv ', ' Current_schema ') from DUAL;    Current mode
sql> SET schema "SYSDBA";   Case sensitive
sql> ALTER SESSION SET current_schema = "SYSDBA";   A way to be very safe

9. Data size

sql> SELECT SUM (bytes) from Dba_data_files; Database Footprint (KB)
sql> select * from V$datafile;//database read/write occupied
sql> SELECT table_used_space (' SYSDBA ', ' D ') * 1024; Table size, Case sensitive

10. Archive Mode

Sql> select Arch_mode from V$database; Whether the archive opens
sql> select * from V$dm_arch_ini;  Archive information

11. Instance Name

12. Other

Sql> select * from systablecomments;    Query system View
sql> Select COUNT (*) from Dba_tables;
Sql> select * from User_tables;
Sql> select * from Dba_tablespaces;
Sql> select * from User_tablespaces;
Sql> SELECT * from All_objects;
Sql> select * from Dba_objects;
Sql> select * from User_objects;
Sql> select * from Dba_users;

13. Special characters
": The default process is to" add one before "as the identity
Command parameter case: Apply \ "\" or it will automatically lowercase to uppercase. The word to be escaped multibyte \

. Text data type
Do not use the ' = ' sign when searching, use link

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.