oracle订阅推送,ERP一部推送 | Oracle优化技术分享
原標(biāo)題:ERP一部推送 | Oracle優(yōu)化技術(shù)分享
看到圖片中酷酷的小哥哥們了嗎?他們是來自中ERP一部的許斌哲,有顏有才的他今天為我們帶來的技術(shù)分享是關(guān)于 Oracle優(yōu)化方面的,歡迎感興趣的小伙伴一起交流哦!
大家好!以下內(nèi)容為個人工作中積累的常見oracle的技術(shù)點(diǎn):
創(chuàng)建一個和a表一樣的空表----create table newtable as select * from a where 1=2;
創(chuàng)建一個和a表一樣的表-----create table newtable as select * from a;
創(chuàng)建一個表---主鍵約束
CREATETABLE stu(
sid CHAR(6) PRIMARY KEY,
sname VARCHAR(20),
age INT,
gender VARCHAR(10)
);
創(chuàng)建一個表---主鍵自增長
CREATE TABLE stu(
sid INT PRIMARY KEY AUTO_INCREMENT,
sname VARCHAR(20),
age INT,
gender VARCHAR(10)
);
----非空約束
CREATE TABLE stu(
sid INT PRIMARY KEY AUTO_INCREMENT,
sname VARCHAR(10) NOT NULL,
age INT,
gender VARCHAR(10)
);
------------唯一約束 類似主鍵
CREATE TABLE tab_ab(
sidINT PRIMARY KEY AUTO_INCREMENT,
snameVARCHAR(10) UNIQUE
);
------------指定外鍵約束
CREATE TABLE t_section(
sid INTPRIMARY KEY AUTO_INCREMENT,
sname VARCHAR(30),
u_id INT,
CONSTRAINT t_user FOREIGN KEY(u_id) REFERENCES t_user(uid)
);
------授權(quán)語句
grant connect ,resource to user1; ---授予用戶權(quán)限
grant connect, resource to user1 with admin option; //可以傳遞所獲權(quán)限。
grant select, update on product to user02 with grant option;
grant create any table,create procedure to role1;
grant role1 to user1;
grant select on table1 to user1;
grant select any table to user1;
給用戶精確賦予權(quán)限
GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,
DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,
DBA,CONNECT,RESOURCE,CREATE SESSION TO 用戶名字
----- 回收權(quán)限
Revoke connect, resource from user50;
Revoke select, update on product from user02;
----插入
insert into newTable select * from oldTable;
insert into Table1(Table1.c1,Table1.c2) select Table2.c1,Table2.c2 from Table2.
----數(shù)據(jù)庫完全導(dǎo)出
exp system/manager@TEST file=d:daochu.dmp full=y
將數(shù)據(jù)庫中system用戶與sys用戶的表導(dǎo)出
exp system/manager@TEST file=d:daochu.dmp owner=(system,sys)
將數(shù)據(jù)庫中的表inner_notify、notify_staff_relat導(dǎo)出
exp aichannel/aichannel@TESTDB2 file= d:datanewsmgnt.dmp tables=(inner_notify,notify_staff_relat)
將數(shù)據(jù)庫中的表table1中的字段filed1以"00"打頭的數(shù)據(jù)導(dǎo)出
exp system/manager@TEST file=d:daochu.dmp tables=(table1) query="""where filed1 like '00%'""" ---注意 雙引號 不能少。
在上面的命令加上 compress=y 來實(shí)現(xiàn)壓縮。
imp aichannel/aichannel@HUST full=y file=d:datanewsmgnt.dmp ignore=y
上面可能有點(diǎn)問題,因?yàn)橛械谋硪呀?jīng)存在,然后它就報錯,對該表就不進(jìn)行導(dǎo)入。
在后面加上 ignore=y 就可以了。
將d:daochu.dmp中的表table1 導(dǎo)入
imp system/manager@TEST file=d:daochu.dmp tables=(table1)
------測試數(shù)據(jù)庫是否可以連接
tnsping orcl
查看用戶表空間使用情況
select
b.file_id 文件ID號,
b.tablespace_name 表空間名,
b.bytes/1024/1024||'M'字節(jié)數(shù),
(b.bytes-sum(nvl(a.bytes,0)))/1024/1024||'M' 已使用,
sum(nvl(a.bytes,0))/1024/1024||'M' 剩余空間,
100 - sum(nvl(a.bytes,0))/(b.bytes)*100 占用百分比
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,b.file_id,b.bytes
order by b.file_id;
查看臨時表空間 (dba_temp_files視圖)(v_$tempfile視圖)
select tablespace_name,file_name,bytes/1024/1024 file_size,autoextensible from dba_temp_files;
select status,enabled, name, bytes/1024/1024 file_size from v$tempfile;--sys用戶查看
查看空間地址
select file_name , tablespace_name from dba_data_files;
查看表空間是否為自動增長
select tablespace_name,file_name,autoextensible from dba_data_files where tablespace_name = 'USERS';
將空間設(shè)置為自動增長
alter database datafile '/home/oracle/ts01.dbf' autoextend on next 5m maxsize unlimited;
將臨時數(shù)據(jù)文件設(shè)為自動擴(kuò)展:
alter database tempfile ‘/u01/app/oracle/oradata/orcl/temp01.dbf’ autoextend on next 5m maxsize unlimited;
增大臨時文件大小:
alter database tempfile ‘/u01/app/oracle/oradata/orcl/temp01.dbf’ resize 100m;
增加文件大小
alter database datafile 'oracleoradataanita_2008.dbf' resize 4000m。
創(chuàng)建臨時表空間
SQL> create temporary tablespace test1temp
tempfile '/home/u01/app/oracle/oradata/ytzx/test1temp01.dbf'
size 10240m
autoextend on next 1024m
maxsize 20480m
extent management local ;
創(chuàng)建數(shù)據(jù)表空間
create tablespace test1
logging
datafile '/home/u01/app/oracle/oradata/ytzx/test1.dbf'
size 10240M --50-100G
autoextend on next 2000M
maxsize unlimited
extent management local autoallocate
segment space management auto ;
同一空間新增存儲文件
ALTER TABLESPACE 表空間名
ADD DATAFILE '數(shù)據(jù)文件路徑'
SIZE 500M
AUTOEXTEND
ON NEXT 1M
MAXSIZE UNLIMITED;
為用戶重新指定表空間 (設(shè)置為自動增長)
alter user username default tablespace userspace;
歡迎 關(guān)注瑞友科技中國事業(yè)部微信公眾號~我們將為大家送上有趣、有料、有溫度、有態(tài)度的各類圖文內(nèi)容,如果你有想要分享或交流的內(nèi)容歡迎隨時@小編進(jìn)行留言~祝工作順利,天天開心!返回搜狐,查看更多
責(zé)任編輯:
總結(jié)
以上是生活随笔為你收集整理的oracle订阅推送,ERP一部推送 | Oracle优化技术分享的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 服务器性能估算参考(硬件-应用服务器)
- 下一篇: 【小松教你手游开发】【unity实用技能