[20190510]快速建立執行指令碼.txt
[20190510]快速建立執行指令碼.txt
--//上午在測試建立表空間備份時,浪費一點點時間.指令碼如下:
$ cat d10.sql
drop tablespace t01 including contents and datafiles;
drop tablespace t02 including contents and datafiles;
drop tablespace t03 including contents and datafiles;
drop tablespace t04 including contents and datafiles;
drop tablespace t05 including contents and datafiles;
drop tablespace t06 including contents and datafiles;
drop tablespace t07 including contents and datafiles;
drop tablespace t08 including contents and datafiles;
drop tablespace t09 including contents and datafiles;
drop tablespace t10 including contents and datafiles;
CREATE TABLESPACE T01 DATAFILE '/mnt/ramdisk/book/T01.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T02 DATAFILE '/mnt/ramdisk/book/T02.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T03 DATAFILE '/mnt/ramdisk/book/T03.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T04 DATAFILE '/mnt/ramdisk/book/T04.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T05 DATAFILE '/mnt/ramdisk/book/T05.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T06 DATAFILE '/mnt/ramdisk/book/T06.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T07 DATAFILE '/mnt/ramdisk/book/T07.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T08 DATAFILE '/mnt/ramdisk/book/T08.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T09 DATAFILE '/mnt/ramdisk/book/T09.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
CREATE TABLESPACE T10 DATAFILE '/mnt/ramdisk/book/T10.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
create table t01 tablespace t01 as select rownum id ,to_char(rownum,'FM000000')||lpad('A',26,'A') name from dual connect by level<=1e5;
create table t02 tablespace t02 as select rownum id ,to_char(rownum,'FM000000')||lpad('B',26,'B') name from dual connect by level<=1e5;
create table t03 tablespace t03 as select rownum id ,to_char(rownum,'FM000000')||lpad('C',26,'C') name from dual connect by level<=1e5;
create table t04 tablespace t04 as select rownum id ,to_char(rownum,'FM000000')||lpad('D',26,'D') name from dual connect by level<=1e5;
create table t05 tablespace t05 as select rownum id ,to_char(rownum,'FM000000')||lpad('E',26,'E') name from dual connect by level<=1e5;
create table t06 tablespace t06 as select rownum id ,to_char(rownum,'FM000000')||lpad('F',26,'F') name from dual connect by level<=1e5;
create table t07 tablespace t07 as select rownum id ,to_char(rownum,'FM000000')||lpad('G',26,'G') name from dual connect by level<=1e5;
create table t08 tablespace t08 as select rownum id ,to_char(rownum,'FM000000')||lpad('H',26,'H') name from dual connect by level<=1e5;
create table t09 tablespace t09 as select rownum id ,to_char(rownum,'FM000000')||lpad('I',26,'I') name from dual connect by level<=1e5;
create table t10 tablespace t10 as select rownum id ,to_char(rownum,'FM000000')||lpad('J',26,'J') name from dual connect by level<=1e5;
alter system checkpoint;
alter system checkpoint;
alter system checkpoint;
--//實際上指令碼很有規律.實際上單獨寫1個,然後替換引數就ok了.
--//我開始copy and paste,一些地方忘記修改了.浪費許多時間.
$ cat dx.sql
drop tablespace t&1 including contents and datafiles;
CREATE TABLESPACE T&1 DATAFILE '/mnt/ramdisk/book/T&1.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON;
create table t&1 tablespace t&1 as select rownum id ,to_char(rownum,'FM000000')||lpad('&&2',26,'&&2') name from dual connect by level<=1e5;
SCOTT@book> @ dx 01 A
old 1: drop tablespace t&1 including contents and datafiles
new 1: drop tablespace t01 including contents and datafiles
Tablespace dropped.
old 1: CREATE TABLESPACE T&1 DATAFILE '/mnt/ramdisk/book/T&1.dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON
new 1: CREATE TABLESPACE T01 DATAFILE '/mnt/ramdisk/book/T01dbf' SIZE 6M AUTOEXTEND OFF LOGGING ONLINE EXTENT MANAGEMENT LOCAL AUTOALLOCATE BLOCKSIZE 8K SEGMENT SPACE MANAGEMENT AUTO FLASHBACK ON
Tablespace created.
old 1: create table t&1 tablespace t&1 as select rownum id ,to_char(rownum,'FM000000')||lpad('&&2',26,'&&2') name from dual connect by level<=1e5
new 1: create table t01 tablespace t01 as select rownum id ,to_char(rownum,'FM000000')||lpad('A',26,'A') name from dual connect by level<=1e5
Table created.
--//這樣又快有簡單,不容易出錯.
--//如何建立1到10個呢?
$ paste -d " " <(seq -f "%02g" 10 ) <((echo A B C D E F G H I J | tr ' ' '\n' )) | xargs -IQ echo @ dx Q
@ dx 01 A
@ dx 02 B
@ dx 03 C
@ dx 04 D
@ dx 05 E
@ dx 06 F
@ dx 07 G
@ dx 08 H
@ dx 09 I
@ dx 10 J
--//執行如下就可以了.
$ paste -d " " <(seq -f "%02g" 10 ) <((echo A B C D E F G H I J | tr ' ' '\n' )) | xargs -IQ echo @ dx Q | sqlplus -s -l scott/book
--//還有一點奇怪的地方是
$ echo $BASH_VERSION
3.2.25(1)-release
$ echo {A..F}| tr ' ' '\n'
A
B
C
D
E
F
--//可以發現可以每行輸出1個.
$ paste -d " " <(seq -f "%02g" 6 ) <(echo {A..F}| tr ' ' '\n' )
01 A B C D E F
02
03
04
05
06
--//感覺這個是BUG(我的測試Oracle Linux Server release 5.9,我感覺這個版本bash的問題多多),我在rhel 7 測試沒有問題.
--//這樣寫就沒有問題.不知道為什麼.
$ paste -d " " <(seq -f "%02g" 6 ) <(echo A B C D E F| tr ' ' '\n' )
01 A
02 B
03 C
04 D
05 E
06 F
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2643900/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 快速建立分支Shell指令碼指令碼
- [20171219]指令碼執行的安全性.txt指令碼
- 執行shell指令碼指令碼
- 指令碼執行方式指令碼
- mybatis執行sql指令碼MyBatisSQL指令碼
- crontab執行shell指令碼指令碼
- PowerShell 指令碼執行策略指令碼
- SQL SERVER執行指令碼SQLServer指令碼
- 指令碼後臺執行指令碼
- 執行python指令碼後臺執行Python指令碼
- 如何在Windows上使用Git建立一個可執行指令碼?WindowsGit指令碼
- [20231021]生成bbed的執行指令碼.txt指令碼
- [20160214]rman執行指令碼註解問題.txt指令碼
- RouterOS 限速指令碼和限執行緒指令碼ROS指令碼執行緒
- appium ios java 指令碼如何用指令執行,例如 adb 那種方式執行指令碼APPiOSJava指令碼
- [20220414]toad呼叫執行指令碼問題.txt指令碼
- C# 執行Javascript指令碼C#JavaScript指令碼
- Selenium執行JavaScript指令碼JavaScript指令碼
- 編寫執行R指令碼指令碼
- 你會執行指令碼嗎指令碼
- 監控sqlldr執行指令碼SQL指令碼
- ANT批量執行Jmeter指令碼JMeter指令碼
- 執行Shell指令碼的方式指令碼
- sh指令碼執行報錯指令碼
- Linux管理指令碼之自動執行指令碼Linux指令碼
- xcall叢集執行命令指令碼指令碼
- Laravel 中執行 Python 指令碼LaravelPython指令碼
- python指令碼後臺執行Python指令碼
- Perl指令碼執行方法小結指令碼
- javascript指令碼何時被執行JavaScript指令碼
- 防止指令碼重複執行方法指令碼
- Oracle用指令碼執行備份Oracle指令碼
- 使用expect執行動態指令碼指令碼
- UNIX crontab自動執行指令碼指令碼
- 執行Shell指令碼的方式(轉)指令碼
- Mac 終端執行 shell 指令碼Mac指令碼
- PHP多程式並行執行php指令碼PHP並行指令碼
- crontab無法執行perl指令碼 手工卻成功執行指令碼