達夢データベース使用心得のまとめ

7719 ワード

達夢データベース使用心得のまとめ
1、先に操作システムを調整する。
(1)ulimit -a     open file      ,   1024,    
(2)     :vi /etc/security/limits.conf    ,      
	*  soft   nofile   102400
	*  hard   nofile   102400
(3)      :ulimit -HSn 102400
2、データベースに掛けるミラーリング
(1)cd /opt
(2)mount -o loop /opt/dm8_setup.iso /mnt
(3)cd /mnt ,ls -ltr
3、インストールデータベースを初期化する
(1)   :groupadd dinstall
(2)    :useradd -g dinstall dmdba
(3)      :passwd dmdba
(4)         ,   :mkdir /dm8   ,chown -R dmdba:dinstall /dm8
(5)  dmdba  。 su - dmdba
(6)  dmdba      :   vi .bash_profile,    :
	export DM_HOME=/dm8
	export PAHT=$PATH:$HOME/.local/bin:$HOME/bin:$DM_HOME/bin:$DM_HOME/tool
4、正式なインストールを開始する:
(1)cd /opt/mnt
(2)      :export DISPLAY=127.0.0.1:2       2 vnc  (          ,        )
(3)       :xhost +  
(4)      :./DMInstall.bin
(5)         ,       dm8
(6)  root  :su - root
(7)         ,  :/dm8/script/root/root_installer.sh,    
5、データベースを初期化する
(1)           ,      :su - dmdba,        :./dm8/tool/dbca.sh
(2)           ,   5236
(3)         ,          
(4)  root  :su - root
(7)         ,         3   ,             ,    
6、データベースに接続する
(1)su – dmdba
(2)     :disql sysdba/     @localhost:5236 ,      ,  :LOGIN,           
(3)    :/dm/tool/manager
7、表空間関連操作
(1)       :
	create tablespace "TEST" datafile '/dm8/data/DAMENG/TBS01.DBF' size 32 autoextend on next 1 CACHE = NORMAL;
(2)       ,     :
	alter tablespace TEST offline;
	alter tablespace TEST online;
(3)       :
	alter tablespace "TEST" resize datafile 'TBS01.DBF' to 64;
(4)             
	select FILE_NAME,STATUS,TABLESPACE_NAME from dba_data_files;
(5)         :
	alter tablespace "TEST" add datafile '/dm8/data/DAMENG/TBS02.DBF' size 64;
(6)           
	①:alter tablespace  "TEST" offline;
	②:select tablespace_name,status from dba_tablespaces;
	③:alter tablespace  "TEST" rename datafile '/dm8/data/DAMENG/TBS02.DBF' to '/dm8/tbs02.dbf';
	④:alter tablespace  "TEST" rename datafile '/dm8/data/DAMENG/TBS02.DBF' to '/dm8/tbs01.dbf';
	⑤:alter tablespace  "TEST" online;
(7)     
	select para_name,para_value from v$dm_ini where para_name like 'TEMP%';
(8)Roll   
	alter tablespace roll resize datafile '/dm8/data/DAMENG/ROLL.DBF' to 256;
(9)     :drop tablespace "TEST";

  :       ,    50M,    2        ,          ,        ,    1M,        100M。
	create tablespace "CESHI" datafile '/dm8/CESHI1.DBF' size 50 autoextend on next 1 maxsize 100, '/dm8/CESHI2.DBF' size 50 autoextend on next 1 maxsize 100 CACHE = NORMAL;
8、ユーザに関する操作
(1)    :    (schema    )drop user test cascade;      :drop user test;

(2)  test       :select grantee,granted_role from SYS.DBA_ROLE_PRIVS where grantee='TEST';

(3)  public       :SELECT GRANTEE,PRIVILEGE FROM SYS.DBA_SYS_PRIVS WHERE GRANTEE='PUBLIC';

  1:    test,          ,         ,       60      。
create user "TEST" identified by "dameng123" limit password_life_time 60 default tablespace "TEST";
grant "PUBLIC","VTI" to "TEST";
grant CREATE TABLE to "TEST";

  2:      test2,   60        ,      2    ,    5   ,     dmhr.employee  
create user "TEST2" identified by "dameng123" limit failed_login_attemps 2, password_life_time 60, password_lock_time 5; 
grant "PUBLIC","VTI" to "TEST2";
grant SELECT on "DMHR"."EMPLOYEE" to "TEST2";

  3:          ,    ,    city     。  :         。
create role "TESTROLE3";
grant REFERENCES ANY TABLE to "TESTROLE3";
grant INSERT on "DMHR"."CITY" to "TESTROLE3";
grant "TESTROLE3" to "TEST2";
9、モード関連操作
(1)   :
create table "TEST"."STU"("ID" CHAR(10) not null,"SNAME" VARCHAR(20) not null ,primary key("ID")) storage(initial 1, next 1, minextents 1,fillfactor 0, on "STU");
comment on table "TEST"."STU" is 'STUDENT INFO';
(2)   :alter table DMHR.TEST add column(AGE INT);    :alter table DMHR.TEST drop column AGE;
(3)        (    )
	    :create table test.t1(id int); alter table test.t1 modify id int not null;
	    :create table test.t3(id int, name varchar(20) unique);
	    :create table test.t4(id int primary key, name varchar(20));
	    :create table test.t6(id int check(id>=5));
	    (           ):create table test.t9(id int primary key,sid int foreign key references test.t8(sid));
(4)    :comment on column test.t8.sid is '  ';
(5)    
	create table test.t10(sid int);
	
	    :vi test.sql,insert into test.t10(sid) values(1);insert into test.t10(sid) values(2);
	  : SQL   :SQL> start /home/dmdba/test.sql
(6)   : alter table test.t1 rename to tt;
(7)       :
	select CONSTRAINT_NAME,CONSTRAINT_TYPE,TABLE_NAME,STATUS from dba_constraints where TABLE_NAME='T3';
	      :alter table test.t3 disable constraint CONS134218845;
	     :alter table test.t3 enable constraint CONS134218845;
(8)   :drop table test.tt;
10、ビューに関する操作:
(1)    :
	    :create view test.v1 as select * from dmhr.employee;
	    :create or replace view test.v1 as select employee_name from dmhr.employee limit 5;
(2)    :drop view test.v1;
(3)    :DBA_VIEWS;
11、インデックス関連操作:
(1)    :select table_name,index_name from dba_indexes where table_name='STU';
(2)    :
		1、       : create tablespace index1 datafile '/dm8/data/DAMENG/index1_01.dbf' size 32;
		2、     :create index ind_emp on test.emp(employee_id) tablespace index1;
		3、      :explain select * from test.emp where employee_id<20;
		4、      :begin  dbms_stats.gather_table_stats('TEST','EMP'); END;
		5、    :alter index test.ind_emp rebuild;
		6、    :drop index test.ind_emp;
12、DML文:
  :insert into test.dept values('1106', 'aaaaa', '9002', 9);
  :delete test.dept where department_id='1106';
MERGE  :  merge into       update  insert   
	merge into test.t1 using test.t12 on (test.t1.c1=test.t12.c3) when MATCHED THEN update set test.t1.c2=test.t12.C4 when not matched then insert (c1,c2) values (test.t12.c3,t12.c4);
13、バックアップの復元
(1)  (    ,  bin    dmap  ):
	1、       :     ;
	2、    -  -  -  
	3、    -  -      -  
	4、    -  -  -  
	5、     -    -      
	6、     -    -    
	
	  :backup database full backupset '/dm8/backup/fullbak2';
	
	  :backup database increment backupset '/dm8/backup/incr_bak';
(2)  ,  Dmrman,  bin  dmrman  ,  DMAN  
	1、    :check backupset '/dm8/backup/fullbak2';
	2、    :estore database '/dm8/data/DAMENG/dm.ini' tablespace test from backupset '/dm8/backup/fullbak2';
(3)     :recover database '/dm8/data/DAMENG/dm.ini' tablespace test;

(4)         :systemctl stop DmServiceDMSERVER.service; systemctl start DmServiceDMSERVER.service;

(5)   (   )
	 1、 dmdba    bin   :./console
	 2、    -   DMAP  -      
	 3、              :systemctl stop DmServiceDMSERVER.service
	 4、  -  -  DB_magic
	 5、systemctl start DmServiceDMSERVER.service;
(6)    :
	  :./dexp SYSDBA/[email protected]:5236 file=dexp01.dmp log=dexp01.log directory=/opt/tools/dm/bakup full=y
	  :./dimp SYSDBA/[email protected]:5236 file=/opt/tools/dm/bakup/dexp01.dmp log=/opt/tools/dm/bakup/dimp01.log SCHEMAS=TEST
14、作業に関する操作
(1)    :  -      
(2)  -    -    -      -    -      
(3)    -        -      
(4)