Dream up a database commonly used functions and commands record - continually updated

Dream up a database record frequently used functions and commands

Dream up a database using statements in general is very close with the oracle of this article is mainly the common case and statements made records and follow-up will continue to constantly updated

Dream up a database commonly used instructions

1.测试查询语句:select 1;
select top 2 from v$dm_ini;
select
from v$dm_ini limit 2;
select * from v$dm_ini where rownum<2;

2. DaMeng case:
Before DM7.6 version default password is converted to uppercase store, pay attention when you log on. For example, the user sets test / test123456, then the login time can log test / TEST123456 and TEST / TEST123456, you can not log in with test1 / test123456 and TEST1 / test123456. Quotes, the actual password is stored If you set a password.
After the default case DM8 common version, the default user name and password are stored unified capital, and letters can be, do all uppercase matching login. Quotes, the actual password is stored If you set a password.

3. Statement stitching with "||", such as: select username || user_id users from dba_users;

4.oracle support wording does not mean, only support the DM <> and =, the following words!
SELECT from DBA_USERS d.username D WHERE <> 'the SYS';
SELECT
from DBA_USERS d.username = D WHERE 'the SYS';!
SELECT * from dba_users d where d.username ^ = ' SYS';

5. Dream of the database table space to create data files require a minimum to 32M. The minimum size of the added data file 4096 page size as the page size is 8K, the minimum value may be added to the file 4096 8K = 32M.

6. Review the implementation plan: explain select ID from TAB1;

Start and stop database connection

启停数据库
[root@dm1 dm]# service DmServiceDMSERVER start
[root@dm1 dm]# service DmServiceDMSERVER stop
[root@dm1 dm]# service DmServiceDMSERVER restart
[root@dm1 dm]# service DmServiceDMSERVER status

Connect to the database
Note: Before connecting a database service has been started and configuration environment variable

Connect command:
disql SYSDBA / SYSDBA

Server [LOCALHOST: 5236]: the open state in the normal
login time: 30.904 (ms)
disql the Build-V7.6.0.77 (2018.07.17-94714) the ENT
Connected to: the DM 7.1.6.77
the SQL>

If no environment variables directly to the bin directory path operation DM
[DM DMl the root @] # SU - dmdba
[dmdba @ DMl dmdbms] $ CD / Home / dmdba / dmdbms / bin
[dmdba @ DMl bin] $ ./ disql SYSDBA / DAMENG123 @ localhost

View configuration information

View of database-related dream
view up to the dream database initialization parameter configuration information
select para_name, para_value from v $ dm_ini limit 5;

See filter database configuration port
select para_name, para_value from v $ dm_ini where para_name like '% PORT%';

View up to the dream database library name
select name, create_time from v $ database ;

View up to the dream state database instance name and
select name, instance_name, start_time, status $ from v $ instance;

View user related
View all database user
select username, user_id, default_tablespace, profile from dba_users;

View all roles
select role from dba_roles;

查看所有表空间
select id,name,max_size,total_size,status$ from v$tablespace;
select tablespace_name,status from dba_tablespaces;

View all data files
select id, path, max_size, free_size , status $ from v $ datafile;

View the log file path information
select path, rlog_size from v $ rlogfile ;

View objects related
to see all objects
SELECT from dba_objects;
SELECT
from dba_objects WHERE Object name like 'the DBA %';
SELECT * WHERE dba_objects from object_name like '% $ V';

See table User objects
select owner, table_name, tablespace_name, status from dba_tables where owner = 'TEST1' limit 5;

View Role Type
select * from dba_roles;

Create a variety of objects

Create a table space is set to automatically expand
create tablespace TBS_TEST datafile 'TBS_TEST01.dbf' size 128 autoextend on;

Create a user default table space
create user USER_TEST identified by "123456789" default tablespace TBS_TEST;

Assigned to the user DBA authority
grant dba to USER_TEST;

The most common table created
Create Table tab_test (int ID, name VARCHAR (10));
INSERT INTO tab_test values (. 1, 'Nl');
INSERT INTO tab_test values (2, 'N2 of');

Create a view
create view v_test as select id, name from tab_test where name = 'N1';

Create a trigger
create table tab_result (log varchar (100 ));

create or replace trigger tri_test
before insert on tab_test
begin
insert into tab_result values(‘插入’);
end;

Create a stored procedure with parameters
Create or Replace Procedure pro_test (in I int)
AS J int; int Total;
the begin
for J in Loop ..i. 1
INSERT INTO tab_test values (J, 'AAAAA');
End Loop;
End;

Call a stored procedure
fut_ccgc_dcs (10);

Guess you like

Origin blog.51cto.com/14615334/2454571