-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatom.xml
3342 lines (2988 loc) · 173 KB
/
atom.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[Strawhouse]]></title>
<link href="http://justlooks.github.com/atom.xml" rel="self"/>
<link href="http://justlooks.github.com/"/>
<updated>2013-02-19T08:47:20+00:00</updated>
<id>http://justlooks.github.com/</id>
<author>
<name><![CDATA[justlooks]]></name>
</author>
<generator uri="http://octopress.org/">Octopress</generator>
<entry>
<title type="html"><![CDATA[用data pump做数据迁移]]></title>
<link href="http://justlooks.github.com/blog/2012/12/17/yong-data-pumpzuo-shu-ju-qian-yi/"/>
<updated>2012-12-17T06:51:00+00:00</updated>
<id>http://justlooks.github.com/blog/2012/12/17/yong-data-pumpzuo-shu-ju-qian-yi</id>
<content type="html"><![CDATA[<p>工作中有个从测试数据库到生产数据库的数据迁移需求,因为是新项目,目前生产区和测试区还没有做隔离
所以我考虑利用data pump和database link做数据迁移,只要1条impdp命令就可以实现</p>
<p>首先创建目标库到测试库的database link</p>
<figure class='code'><figcaption><span>create database link </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SQL> create public database link rac1_bm_lk connect to bm_zny identified by <span class="s2">"123456"</span> using <span class="s1">'172.20.101.202:1521/testdb'</span>;
</span></code></pre></td></tr></table></div></figure>
<p>然后赋予目标库帐号imp_full_database角色 (之前帐号需要有connect ,resource角色)</p>
<figure class='code'><figcaption><span>grant imp_full_database </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SQL> grant imp_full_database to testme;
</span></code></pre></td></tr></table></div></figure>
<p>进行导入操作</p>
<figure class='code'><figcaption><span>impdp import data </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>impdp testme/123456 <span class="nv">schemas</span><span class="o">=</span>bm_hch <span class="nv">network_link</span><span class="o">=</span>rac1_bm_lk <span class="nv">logfile</span><span class="o">=</span>bm2rac.log <span class="nv">remap_schema</span><span class="o">=</span>bm_hch:testme <span class="nv">remap_tablespace</span><span class="o">=</span>users:sinopay_u
</span><span class='line'>
</span><span class='line'><span class="c">#最后返回导入错误信息</span>
</span><span class='line'>Processing object <span class="nb">type </span>SCHEMA_EXPORT/TABLE/INDEX/INDEX
</span><span class='line'>Processing object <span class="nb">type </span>SCHEMA_EXPORT/TABLE/CONSTRAINT/CONSTRAINT
</span><span class='line'>Processing object <span class="nb">type </span>SCHEMA_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
</span><span class='line'>Processing object <span class="nb">type </span>SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
</span><span class='line'>Processing object <span class="nb">type </span>SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
</span><span class='line'>ORA-39082: Object <span class="nb">type </span>ALTER_PACKAGE_SPEC:<span class="s2">"TESTME"</span>.<span class="s2">"MIGRATION"</span> created with compilation warnings
</span><span class='line'>Processing object <span class="nb">type </span>SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
</span><span class='line'>ORA-39082: Object <span class="nb">type </span>PACKAGE_BODY:<span class="s2">"TESTME"</span>.<span class="s2">"MD_META"</span> created with compilation warnings
</span><span class='line'>ORA-39082: Object <span class="nb">type </span>PACKAGE_BODY:<span class="s2">"TESTME"</span>.<span class="s2">"MIGRATION"</span> created with compilation warnings
</span><span class='line'>ORA-39082: Object <span class="nb">type </span>PACKAGE_BODY:<span class="s2">"TESTME"</span>.<span class="s2">"MIGRATION_REPORT"</span> created with compilation warnings
</span><span class='line'>ORA-39082: Object <span class="nb">type </span>PACKAGE_BODY:<span class="s2">"TESTME"</span>.<span class="s2">"MIGRATION_TRANSFORMER"</span> created with compilation warnings
</span><span class='line'>Processing object <span class="nb">type </span>SCHEMA_EXPORT/TABLE/TRIGGER
</span><span class='line'>Processing object <span class="nb">type </span>SCHEMA_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
</span><span class='line'>Job <span class="s2">"TESTME"</span>.<span class="s2">"SYS_IMPORT_SCHEMA_01"</span> completed with 6 error<span class="o">(</span>s<span class="o">)</span> at 14:48:40
</span></code></pre></td></tr></table></div></figure>
<p>查了下metalink相关文档为
Impdp Returns ORA-39082 When Importing Wrapped Procedures [ID 460267.1]</p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[设置sqlplus环境]]></title>
<link href="http://justlooks.github.com/blog/2012/12/03/she-zhi-sqlplushuan-jing/"/>
<updated>2012-12-03T01:10:00+00:00</updated>
<id>http://justlooks.github.com/blog/2012/12/03/she-zhi-sqlplushuan-jing</id>
<content type="html"><![CDATA[<p>sqlplus在启动时会运行glogin.sql和login.sql两个脚本,来加载sqlplus的环境配置
顺序是先<br/>
在$ORACLE_HOME/sqlplus/admin下找glogin.sql,并运行,然后在当前路径下找
login.sql<br/>
文件,如果没找到则查找是否设置SQLPATH环境变量,如果设置在该路径下找,
如果没找到则<br/>
不再查找</p>
<figure class='code'><figcaption><span>content of glogin.sql </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
<span class='line-number'>54</span>
<span class='line-number'>55</span>
<span class='line-number'>56</span>
<span class='line-number'>57</span>
<span class='line-number'>58</span>
<span class='line-number'>59</span>
<span class='line-number'>60</span>
<span class='line-number'>61</span>
<span class='line-number'>62</span>
<span class='line-number'>63</span>
<span class='line-number'>64</span>
<span class='line-number'>65</span>
<span class='line-number'>66</span>
<span class='line-number'>67</span>
<span class='line-number'>68</span>
<span class='line-number'>69</span>
<span class='line-number'>70</span>
<span class='line-number'>71</span>
<span class='line-number'>72</span>
<span class='line-number'>73</span>
<span class='line-number'>74</span>
<span class='line-number'>75</span>
<span class='line-number'>76</span>
<span class='line-number'>77</span>
<span class='line-number'>78</span>
<span class='line-number'>79</span>
<span class='line-number'>80</span>
<span class='line-number'>81</span>
<span class='line-number'>82</span>
<span class='line-number'>83</span>
<span class='line-number'>84</span>
<span class='line-number'>85</span>
<span class='line-number'>86</span>
<span class='line-number'>87</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nb">set </span>termout off
</span><span class='line'>column global_name new_value gname
</span><span class='line'>define <span class="nv">gname</span><span class="o">=</span>idle
</span><span class='line'><span class="k">select </span>upper<span class="o">(</span>user<span class="o">)||</span><span class="s1">'@'</span><span class="o">||</span> instance_name||<span class="s1">'/'</span><span class="o">||</span>host_name global_name from v<span class="nv">$instance</span>;
</span><span class='line'>alter session <span class="nb">set </span><span class="nv">nls_date_format</span><span class="o">=</span><span class="s1">'yyyy-mm-dd hh24:mi:ss'</span>;
</span><span class='line'><span class="nb">set </span>termout on
</span><span class='line'>
</span><span class='line'><span class="nb">set </span>sqlprompt <span class="s1">'&gname> '</span>
</span><span class='line'>
</span><span class='line'><span class="nb">set </span>timing on
</span><span class='line'><span class="nv">define_editor</span><span class="o">=</span>vi
</span><span class='line'><span class="nb">set </span>serveroutput on size 1000000 format wrapped
</span><span class='line'><span class="nb">set </span>linesize 170
</span><span class='line'><span class="nb">set </span>pagesize 80
</span><span class='line'><span class="nb">set </span>newpage none
</span><span class='line'><span class="nb">set </span>long 1000
</span><span class='line'>column plan_plus_exp format a80
</span><span class='line'><span class="nb">set </span>trimspool on
</span><span class='line'>
</span><span class='line'>col c1 format a1
</span><span class='line'>col cc1 format a1
</span><span class='line'>col c2 format a2
</span><span class='line'>col cc2 format a2
</span><span class='line'>col c3 format a3
</span><span class='line'>col cc3 format a3
</span><span class='line'>col c4 format a4
</span><span class='line'>col cc4 format a4
</span><span class='line'>col c5 format a5
</span><span class='line'>col cc5 format a5
</span><span class='line'>col c6 format a6
</span><span class='line'>col cc6 format a6
</span><span class='line'>col c7 format a7
</span><span class='line'>col cc7 format a7
</span><span class='line'>col c8 format a8
</span><span class='line'>col cc8 format a8
</span><span class='line'>col c9 format a9
</span><span class='line'>col cc9 format a9
</span><span class='line'>col c10 format a10
</span><span class='line'>col cc10 format a10
</span><span class='line'>col c15 format a15
</span><span class='line'>col cc15 format a15
</span><span class='line'>col c20 format a20
</span><span class='line'>col cc20 format a20
</span><span class='line'>col c30 format a30
</span><span class='line'>col cc30 format a30
</span><span class='line'>col c40 format a40
</span><span class='line'>col cc40 format a40
</span><span class='line'>col c50 format a50
</span><span class='line'>col cc50 format a50
</span><span class='line'>col c60 format a60
</span><span class='line'>col cc60 format a60
</span><span class='line'>col c70 format a70
</span><span class='line'>col cc70 format a70
</span><span class='line'>col c80 format a80
</span><span class='line'>col cc80 format a80
</span><span class='line'>col c90 format a90
</span><span class='line'>col cc90 format a90
</span><span class='line'>col c100 format a100
</span><span class='line'>col cc100 format a100
</span><span class='line'>col c150 format a150
</span><span class='line'>col cc150 format a150
</span><span class='line'>col c200 format a200
</span><span class='line'>col cc200 format a200
</span><span class='line'>col c255 format a255
</span><span class='line'>col cc255 format a255
</span><span class='line'>col host format a30
</span><span class='line'>col db_link format a30
</span><span class='line'>col host format a30
</span><span class='line'>col db_link format a30
</span><span class='line'>col member format a60
</span><span class='line'>col name format a60
</span><span class='line'>col owner format a15
</span><span class='line'>col what format a90
</span><span class='line'>col DEST_NAME format a30
</span><span class='line'>col OS_USERNAME format a15
</span><span class='line'>col USERNAME format a15
</span><span class='line'>col USERHOST format a15
</span><span class='line'>col TERMINAL format a15
</span><span class='line'>col OBJ_NAME format a30
</span><span class='line'>col SQL_TEXT format a60
</span><span class='line'>col EVENT format a70
</span><span class='line'>col status format a60
</span><span class='line'>col MESSAGE format a100
</span><span class='line'>col path format a30
</span><span class='line'>col FILE_NAME format a60
</span><span class='line'>col DESTINATION format a50
</span><span class='line'>col OBJECT_NAME format a30
</span></code></pre></td></tr></table></div></figure>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[蜜豆双皮奶制作方法]]></title>
<link href="http://justlooks.github.com/blog/2012/12/02/mi-dou-shuang-pi-nai-zhi-zuo-fang-fa/"/>
<updated>2012-12-02T12:35:00+00:00</updated>
<id>http://justlooks.github.com/blog/2012/12/02/mi-dou-shuang-pi-nai-zhi-zuo-fang-fa</id>
<content type="html"><![CDATA[<p><strong>首先是蜜豆的做法:</strong></p>
<pre><code>1. 将赤豆用水泡24小时(我因为断煤气泡了36个小时- -)
2. 1份赤豆3份水,将水烧开倒入赤豆,烧开转小火煮
3. 水烧到1/3后加糖,可以是冰糖(我加了红糖)
4. 烧到水快干了就做好了
</code></pre>
<hr />
<p><strong>下面是双皮奶的做法:</strong></p>
<pre><code>1. 200ML牛奶,小火煮到快开不开状态,倒入碗中放冰箱凉出奶皮
2. 1个鸡蛋分出蛋清,打碎加入10G糖
3. 将牛奶倒入蛋清混合均匀(奶皮留原来碗里)
4. 将3中混合物倒回碗里,隔水蒸10分钟
5. 放凉加蜜豆,功成
</code></pre>
<p>糖不需要太多,甜味靠蜜豆,双皮奶嫩滑有浓郁的奶味,蜜豆咬起来非常软,很好吃</p>
<p><img src="http://farm9.staticflickr.com/8067/8236700191_9260fe575b_m.jpg" title="好吃的蜜豆双皮奶" alt="我的图片" /></p>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[oracle删除某个用户所有连接脚本]]></title>
<link href="http://justlooks.github.com/blog/2012/11/24/oracleshan-chu-mou-ge-yong-hu-suo-you-lian-jie-jiao-ben/"/>
<updated>2012-11-24T07:02:00+00:00</updated>
<id>http://justlooks.github.com/blog/2012/11/24/oracleshan-chu-mou-ge-yong-hu-suo-you-lian-jie-jiao-ben</id>
<content type="html"><![CDATA[<p>删除某个用户的所有连接会话,需要查询v$session视图得到sid和serial,来调用kill命令
下面是封装脚本</p>
<figure class='code'><figcaption><span>kill all connect of one user </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>PROMPT Enter username which u want to kick
</span><span class='line'>ACCEPT KUSER PROMPT <span class="s1">'User: '</span>
</span><span class='line'><span class="nb">set </span>serveroutput on
</span><span class='line'>DECLARE
</span><span class='line'> TYPE kicktyp IS REF CURSOR;
</span><span class='line'> TYPE sidlist IS TABLE OF NUMBER;
</span><span class='line'> TYPE seriallist IS TABLE OF NUMBER;
</span><span class='line'> kick_cur kicktyp;
</span><span class='line'> sidarr sidlist;
</span><span class='line'> serialarr seriallist;
</span><span class='line'> kstr VARCHAR2<span class="o">(</span>200<span class="o">)</span>;
</span><span class='line'>BEGIN
</span><span class='line'> OPEN kick_cur FOR
</span><span class='line'> <span class="k">select </span>sid,serial# from v<span class="nv">$session</span> where <span class="nv">username</span><span class="o">=</span>UPPER<span class="o">(</span><span class="s1">'&KUSER'</span><span class="o">)</span>;
</span><span class='line'>
</span><span class='line'> FETCH kick_cur BULK COLLECT INTO sidarr,serialarr;
</span><span class='line'> CLOSE kick_cur;
</span><span class='line'> FOR i IN sidarr.FIRST .. sidarr.LAST
</span><span class='line'> LOOP
</span><span class='line'> DBMS_OUTPUT.put_line<span class="o">(</span><span class="s1">'i find sid '</span><span class="o">||</span>sidarr<span class="o">(</span>i<span class="o">)||</span><span class="s1">' serial# '</span><span class="o">||</span>serialarr<span class="o">(</span>i<span class="o">)||</span><span class="s1">' should close!'</span><span class="o">)</span>;
</span><span class='line'> kstr:<span class="o">=</span><span class="s1">'ALTER SYSTEM KILL SESSION '</span><span class="o">||</span>q<span class="s1">'{'</span><span class="o">}</span><span class="s1">'||sidarr(i)||'</span>,<span class="s1">'||serialarr(i)||q'</span><span class="o">{</span><span class="s1">'}'</span>;
</span><span class='line'> execute immediate kstr;
</span><span class='line'> END LOOP;
</span><span class='line'>END;
</span><span class='line'>/
</span></code></pre></td></tr></table></div></figure>
<p>下面是执行效果</p>
<figure class='code'><figcaption><span>execute script </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SQL> @/home/oracle/scripts/kick_user.ora
</span><span class='line'>Enter username which u want to kick
</span><span class='line'>User: bm_user
</span><span class='line'>old 12: <span class="k">select </span>sid,serial# from v<span class="nv">$session</span> where <span class="nv">username</span><span class="o">=</span>UPPER<span class="o">(</span><span class="s1">'&KUSER'</span><span class="o">)</span>;
</span><span class='line'>new 12: <span class="k">select </span>sid,serial# from v<span class="nv">$session</span> where <span class="nv">username</span><span class="o">=</span>UPPER<span class="o">(</span><span class="s1">'bm_user'</span><span class="o">)</span>;
</span><span class='line'>i find sid 154 serial# 109 should close!
</span><span class='line'>
</span><span class='line'>SQL> conn bm_user/123456
</span><span class='line'>Connected.
</span><span class='line'>SQL> <span class="k">select </span>userenv<span class="o">(</span><span class="s1">'sessionid'</span><span class="o">)</span> from dual;
</span><span class='line'><span class="k">select </span>userenv<span class="o">(</span><span class="s1">'sessionid'</span><span class="o">)</span> from dual
</span><span class='line'>*
</span><span class='line'>ERROR at line 1:
</span><span class='line'>ORA-00028: your session has been killed
</span></code></pre></td></tr></table></div></figure>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[关于oracle自增主键]]></title>
<link href="http://justlooks.github.com/blog/2012/11/23/guan-yu-oraclezi-zeng-zhu-jian/"/>
<updated>2012-11-23T01:19:00+00:00</updated>
<id>http://justlooks.github.com/blog/2012/11/23/guan-yu-oraclezi-zeng-zhu-jian</id>
<content type="html"><![CDATA[<p>在MYSQL中自增列可以用auto_increment这个列属性实现,而在oracle下面没有,但是oracle有个sequence可以通过触发器间接实现自增功能
下面是实现的代码</p>
<figure class='code'><figcaption><span>auto_increment use seqence </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>drop table test1;
</span><span class='line'>drop sequence myseq;
</span><span class='line'>create table test1<span class="o">(</span>id number,name varchar2<span class="o">(</span>20<span class="o">))</span>;
</span><span class='line'>create sequence myseq increment by 1 start with 1 maxvalue 999999 minvalue 1 nocache nocycle;
</span><span class='line'>create or replace trigger test1_trg_b_i before insert on test1 <span class="k">for </span>each row
</span><span class='line'>begin
</span><span class='line'> <span class="k">select </span>myseq.nextval into :new.id from dual;
</span><span class='line'>end;
</span><span class='line'>/
</span><span class='line'>DECLARE
</span><span class='line'> i number default 1;
</span><span class='line'>BEGIN
</span><span class='line'><span class="k">for </span>i in 1..1000 loop
</span><span class='line'> insert into test1<span class="o">(</span>name<span class="o">)</span> values<span class="o">(</span><span class="s1">'aaa'</span><span class="o">)</span>;
</span><span class='line'>end loop;
</span><span class='line'>END;
</span><span class='line'>/
</span><span class='line'><span class="k">select </span>count<span class="o">(</span>distinct<span class="o">(</span>id<span class="o">))</span> from test1;
</span></code></pre></td></tr></table></div></figure>
<p>另外一个列子是实现MYSQL中last_insert_id调用的oracle实现</p>
<figure class='code'><figcaption><span>last insert id </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nb">set </span>serveroutput on
</span><span class='line'><span class="nb">declare</span>
</span><span class='line'><span class="nb"> </span>myid test1.id%TYPE;
</span><span class='line'>BEGIN
</span><span class='line'>insert into test1<span class="o">(</span>name<span class="o">)</span> values<span class="o">(</span><span class="s1">'bbb'</span><span class="o">)</span> RETURNING id into myid;
</span><span class='line'>DBMS_OUTPUT.put_line<span class="o">(</span><span class="s1">'result : '</span> <span class="o">||</span> myid<span class="o">)</span>;
</span><span class='line'>END;
</span></code></pre></td></tr></table></div></figure>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[使用logminer挖掘redo log]]></title>
<link href="http://justlooks.github.com/blog/2012/11/02/shi-yong-logminerwa-jue-redo-log/"/>
<updated>2012-11-02T00:33:00+00:00</updated>
<id>http://justlooks.github.com/blog/2012/11/02/shi-yong-logminerwa-jue-redo-log</id>
<content type="html"><![CDATA[<p>oracle提供了logminer工具,可以对online redo log或者archive log做方便的检视
下面是工具使用的简单演示</p>
<p>使用logminer的条件是开启minimal level supplemental logging</p>
<figure class='code'><figcaption><span>enable minimal level supplemental logging </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SQL> <span class="k">select </span>supplemental_log_data_min from v<span class="nv">$database</span>;
</span><span class='line'>
</span><span class='line'>SUPPLEME
</span><span class='line'>--------
</span><span class='line'>NO
</span><span class='line'>
</span><span class='line'>SQL> alter database add supplemental log data;
</span><span class='line'>
</span><span class='line'>Database altered.
</span><span class='line'>
</span><span class='line'>SQL> <span class="k">select </span>supplemental_log_data_min from v<span class="nv">$database</span>;
</span><span class='line'>
</span><span class='line'>SUPPLEME
</span><span class='line'>--------
</span><span class='line'>YES
</span></code></pre></td></tr></table></div></figure>
<p>另外如果是手动创建数据库的话,logminer是需要额外安装的,dbca建库会自动安装</p>
<figure class='code'><figcaption><span>install logminer </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="c">#判断是否安装logminer相关package</span>
</span><span class='line'>
</span><span class='line'>SQL> desc dbms_logmnr;
</span><span class='line'>SQL> desc dbms_logmnr_d;
</span><span class='line'>SQL> desc dbms_logmnr_session;
</span><span class='line'>
</span><span class='line'><span class="c"># 以上3个包的安装文件分别对应为</span>
</span><span class='line'>
</span><span class='line'><span class="nv">$ORACLE_HOME</span>/rdbms/admin/dbmslm.sql
</span><span class='line'><span class="nv">$ORACLE_HOME</span>/rdbms/admin/dbmslmd.sql
</span><span class='line'><span class="nv">$ORACLE_HOME</span>/rdbms/admin/dbmslms.sql
</span></code></pre></td></tr></table></div></figure>
<p>选择在线日志(也可以是archive log)</p>
<figure class='code'><figcaption><span>status of redo log </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SQL> <span class="k">select </span>sequence#,name,status,deleted from v<span class="nv">$archived_log</span> where <span class="nv">deleted</span><span class="o">=</span><span class="s1">'NO'</span>;
</span><span class='line'>
</span><span class='line'> SEQUENCE# NAME S DEL
</span><span class='line'>---------- ---------------------------------------------------------------------- - ---
</span><span class='line'> 119 +MYDG/mycatalog/archivelog/2012_10_29/thread_1_seq_119.357.797983263 A NO
</span><span class='line'> 120 +MYDG/mycatalog/archivelog/2012_10_30/thread_1_seq_120.355.798020785 A NO
</span><span class='line'> 121 +MYDG/mycatalog/archivelog/2012_10_30/thread_1_seq_121.353.798037233 A NO
</span><span class='line'> 122 +MYDG/mycatalog/archivelog/2012_10_30/thread_1_seq_122.351.798069683 A NO
</span><span class='line'> 123 +MYDG/mycatalog/archivelog/2012_10_31/thread_1_seq_123.350.798107255 A NO
</span><span class='line'> 124 +MYDG/mycatalog/archivelog/2012_10_31/thread_1_seq_124.328.798120041 A NO
</span><span class='line'> 125 +MYDG/mycatalog/archivelog/2012_10_31/thread_1_seq_125.327.798156075 A NO
</span><span class='line'> 126 +MYDG/mycatalog/archivelog/2012_11_01/thread_1_seq_126.324.798193729 A NO
</span><span class='line'> 127 +MYDG/mycatalog/archivelog/2012_11_01/thread_1_seq_127.323.798205101 A NO
</span><span class='line'>
</span><span class='line'>SQL> <span class="k">select </span>f.group#,l.sequence#,l.status,f.member from v<span class="nv">$logfile</span> f inner join v<span class="nv">$log</span> l on f.group# <span class="o">=</span> l.group#;
</span><span class='line'>
</span><span class='line'> GROUP# SEQUENCE# STATUS MEMBER
</span><span class='line'>---------- ---------- ---------------- ------------------------------------------------------------
</span><span class='line'> 3 126 INACTIVE +MYDG/mycatalog/onlinelog/group_3.279.794511165
</span><span class='line'> 3 126 INACTIVE +MYDG/mycatalog/onlinelog/group_3.282.794511167
</span><span class='line'> 2 128 CURRENT +MYDG/mycatalog/onlinelog/group_2.283.794511165
</span><span class='line'> 2 128 CURRENT +MYDG/mycatalog/onlinelog/group_2.281.794511165
</span><span class='line'> 1 127 INACTIVE +MYDG/mycatalog/onlinelog/group_1.285.794511163
</span><span class='line'> 1 127 INACTIVE +MYDG/mycatalog/onlinelog/group_1.284.794511163
</span></code></pre></td></tr></table></div></figure>
<p>另外开个session执行hr schema中t1表的改变</p>
<figure class='code'><figcaption><span>change table t1 </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'><span class="nv">$ </span>sqlplus hr/hr
</span><span class='line'>
</span><span class='line'>SQL> <span class="k">select</span> * from t1;
</span><span class='line'>
</span><span class='line'> ID NAME
</span><span class='line'>---------- ----------
</span><span class='line'> 2 kkk
</span><span class='line'> 3 tttt
</span><span class='line'> 1 recovery
</span><span class='line'>
</span><span class='line'>SQL> delete from t1 where <span class="nv">name</span><span class="o">=</span><span class="s1">'kkk'</span>;
</span><span class='line'>
</span><span class='line'>1 row deleted.
</span><span class='line'>
</span><span class='line'>SQL> update t1 <span class="nb">set </span><span class="nv">name</span><span class="o">=</span><span class="s1">'logmnr'</span> where <span class="nv">id</span><span class="o">=</span>3;
</span><span class='line'>
</span><span class='line'>1 row updated.
</span><span class='line'>
</span><span class='line'>SQL> commit;
</span><span class='line'>
</span><span class='line'>Commit complete.
</span><span class='line'>
</span><span class='line'>SQL> <span class="k">select</span> * from t1;
</span><span class='line'>
</span><span class='line'> ID NAME
</span><span class='line'>---------- ----------
</span><span class='line'> 3 logmnr
</span><span class='line'> 1 recovery
</span></code></pre></td></tr></table></div></figure>
<p>将group 2中的其中一个member做为挖掘对象</p>
<figure class='code'><figcaption><span>logminer process </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SQL> BEGIN
</span><span class='line'> 2 dbms_logmnr.add_logfile <span class="o">(</span><span class="s1">'+MYDG/mycatalog/onlinelog/group_2.283.794511165'</span><span class="o">)</span>;
</span><span class='line'> 3 END;
</span><span class='line'> 4 /
</span><span class='line'>
</span><span class='line'>PL/SQL procedure successfully completed.
</span><span class='line'>
</span><span class='line'>SQL> BEGIN
</span><span class='line'> 2 dbms_logmnr.start_logmnr<span class="o">(</span><span class="nv">options</span> <span class="o">=</span>> dbms_logmnr.dict_from_online_catalog<span class="o">)</span>;
</span><span class='line'> 3 END;
</span><span class='line'> 4 /
</span><span class='line'>
</span><span class='line'>PL/SQL procedure successfully completed.
</span></code></pre></td></tr></table></div></figure>
<p>抓取需要的记录</p>
<figure class='code'><figcaption><span>get useful info </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SQL> <span class="k">select </span>OBJECT_ID,data_object_id from dba_objects where <span class="nv">owner</span><span class="o">=</span><span class="s1">'HR'</span> and <span class="nv">OBJECT_NAME</span><span class="o">=</span><span class="s1">'T1'</span>;
</span><span class='line'>
</span><span class='line'> OBJECT_ID DATA_OBJECT_ID
</span><span class='line'>---------- --------------
</span><span class='line'> 77065 77065
</span><span class='line'>
</span><span class='line'>SQL> SELECT username AS USR, <span class="o">(</span>XIDUSN <span class="o">||</span> <span class="s1">'.'</span> <span class="o">||</span> XIDSLT <span class="o">||</span> <span class="s1">'.'</span> <span class="o">||</span> XIDSQN<span class="o">)</span> AS XID,
</span><span class='line'> 2 SQL_REDO, SQL_UNDO FROM V<span class="nv">$LOGMNR_CONTENTS</span> WHERE DATA_OBJ#<span class="o">=</span>77065;
</span><span class='line'>
</span><span class='line'>USR XID
</span><span class='line'>------------------------------ --------------------------------------------------------------------------------------------------------------------------
</span><span class='line'>SQL_REDO
</span><span class='line'>--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
</span><span class='line'>SQL_UNDO
</span><span class='line'>--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
</span><span class='line'>UNKNOWN 8.22.2258
</span><span class='line'>update <span class="s2">"HR"</span>.<span class="s2">"T1"</span> <span class="nb">set</span> <span class="s2">"NAME"</span> <span class="o">=</span> <span class="s1">'logmnr'</span> where <span class="s2">"NAME"</span> <span class="o">=</span> <span class="s1">'tttt'</span> and <span class="nv">ROWID</span> <span class="o">=</span> <span class="s1">'AAAS0JAAFAAACi2AAA'</span>;
</span><span class='line'>update <span class="s2">"HR"</span>.<span class="s2">"T1"</span> <span class="nb">set</span> <span class="s2">"NAME"</span> <span class="o">=</span> <span class="s1">'tttt'</span> where <span class="s2">"NAME"</span> <span class="o">=</span> <span class="s1">'logmnr'</span> and <span class="nv">ROWID</span> <span class="o">=</span> <span class="s1">'AAAS0JAAFAAACi2AAA'</span>;
</span></code></pre></td></tr></table></div></figure>
]]></content>
</entry>
<entry>
<title type="html"><![CDATA[表空间传输]]></title>
<link href="http://justlooks.github.com/blog/2012/10/26/biao-kong-jian-chuan-shu/"/>
<updated>2012-10-26T14:37:00+00:00</updated>
<id>http://justlooks.github.com/blog/2012/10/26/biao-kong-jian-chuan-shu</id>
<content type="html"><![CDATA[<h2>下面演示一下用expdp/impdp进行表空间传输的过程</h2>
<p>创建测试数据</p>
<figure class='code'><figcaption><span>use for test </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
<span class='line-number'>54</span>
<span class='line-number'>55</span>
<span class='line-number'>56</span>
<span class='line-number'>57</span>
<span class='line-number'>58</span>
<span class='line-number'>59</span>
<span class='line-number'>60</span>
<span class='line-number'>61</span>
<span class='line-number'>62</span>
<span class='line-number'>63</span>
<span class='line-number'>64</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SQL> <span class="k">select </span>tablespace_name from dba_tablespaces;
</span><span class='line'>
</span><span class='line'>TABLESPACE_NAME
</span><span class='line'>------------------------------
</span><span class='line'>SYSTEM
</span><span class='line'>SYSAUX
</span><span class='line'>UNDOTBS1
</span><span class='line'>TEMP
</span><span class='line'>USERS
</span><span class='line'>TS_EXAMPLE
</span><span class='line'>TS_FBDA
</span><span class='line'>
</span><span class='line'>SQL> create tablespace tbs_his;
</span><span class='line'>
</span><span class='line'>Tablespace created.
</span><span class='line'>
</span><span class='line'>SQL> create tablespace tbs_his_idx;
</span><span class='line'>
</span><span class='line'>Tablespace created.
</span><span class='line'>
</span><span class='line'>SQL> <span class="k">select </span>tablespace_name from dba_tablespaces;
</span><span class='line'>
</span><span class='line'>TABLESPACE_NAME
</span><span class='line'>------------------------------
</span><span class='line'>SYSTEM
</span><span class='line'>SYSAUX
</span><span class='line'>UNDOTBS1
</span><span class='line'>TEMP
</span><span class='line'>USERS
</span><span class='line'>TS_EXAMPLE
</span><span class='line'>TS_FBDA
</span><span class='line'>TBS_HIS
</span><span class='line'>TBS_HIS_IDX
</span><span class='line'>
</span><span class='line'>9 rows selected.
</span><span class='line'>
</span><span class='line'>SQL> conn hr/hr
</span><span class='line'>Connected.
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>SQL> create table order_history <span class="o">(</span>id int<span class="o">)</span> tablespace tbs_his;
</span><span class='line'>
</span><span class='line'>Table created.
</span><span class='line'>
</span><span class='line'>SQL> insert into order_history values<span class="o">(</span>999<span class="o">)</span>;
</span><span class='line'>
</span><span class='line'>1 row created.
</span><span class='line'>
</span><span class='line'>SQL> commit;
</span><span class='line'>
</span><span class='line'>Commit complete.
</span><span class='line'>
</span><span class='line'>SQL> create index idx_id on order_history<span class="o">(</span>id<span class="o">)</span> tablespace tbs_his_idx;
</span><span class='line'>
</span><span class='line'>Index created.
</span><span class='line'>
</span><span class='line'>SQL> <span class="k">select </span>table_name as object_name ,tablespace_name from user_tables where <span class="nv">table_name</span><span class="o">=</span><span class="s1">'ORDER_HISTORY'</span> union <span class="k">select </span>index_name as
</span><span class='line'>
</span><span class='line'>object_name, tablespace_name from user_indexes where <span class="nv">index_name</span><span class="o">=</span><span class="s1">'IDX_ID'</span>;
</span><span class='line'>
</span><span class='line'>OBJECT_NAME TABLESPACE_NAME
</span><span class='line'>------------------------------ ------------------------------
</span><span class='line'>IDX_ID TBS_HIS_IDX
</span><span class='line'>ORDER_HISTORY TBS_HIS
</span></code></pre></td></tr></table></div></figure>
<p>检查下空间是否是自包含的</p>
<figure class='code'><figcaption><span>check if self-contained </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SQL> execute dbms_tts.transport_set_check<span class="o">(</span><span class="s1">'TBS_HIS_IDX,TBS_HIS'</span>,TRUE<span class="o">)</span>;
</span><span class='line'>
</span><span class='line'>PL/SQL procedure successfully completed.
</span><span class='line'>
</span><span class='line'>SQL> <span class="k">select</span> * from transport_set_violations;
</span><span class='line'>
</span><span class='line'>no rows selected
</span></code></pre></td></tr></table></div></figure>
<p>改为只读模式并用expdp导出</p>
<figure class='code'><figcaption><span>export tablespaces </span></figcaption>
<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
<span class='line-number'>16</span>
<span class='line-number'>17</span>
<span class='line-number'>18</span>
<span class='line-number'>19</span>
<span class='line-number'>20</span>
<span class='line-number'>21</span>
<span class='line-number'>22</span>
<span class='line-number'>23</span>
<span class='line-number'>24</span>
<span class='line-number'>25</span>
<span class='line-number'>26</span>
<span class='line-number'>27</span>
<span class='line-number'>28</span>
<span class='line-number'>29</span>
<span class='line-number'>30</span>
<span class='line-number'>31</span>
<span class='line-number'>32</span>
<span class='line-number'>33</span>
<span class='line-number'>34</span>
<span class='line-number'>35</span>
<span class='line-number'>36</span>
<span class='line-number'>37</span>
<span class='line-number'>38</span>
<span class='line-number'>39</span>
<span class='line-number'>40</span>
<span class='line-number'>41</span>
<span class='line-number'>42</span>
<span class='line-number'>43</span>
<span class='line-number'>44</span>
<span class='line-number'>45</span>
<span class='line-number'>46</span>
<span class='line-number'>47</span>
<span class='line-number'>48</span>
<span class='line-number'>49</span>
<span class='line-number'>50</span>
<span class='line-number'>51</span>
<span class='line-number'>52</span>
<span class='line-number'>53</span>
<span class='line-number'>54</span>
</pre></td><td class='code'><pre><code class='bash'><span class='line'>SQL> alter tablespace TBS_HIS <span class="nb">read </span>only;
</span><span class='line'>
</span><span class='line'>Tablespace altered.
</span><span class='line'>
</span><span class='line'>SQL> alter tablespace TBS_HIS_IDX <span class="nb">read </span>only;
</span><span class='line'>
</span><span class='line'>Tablespace altered.
</span><span class='line'>
</span><span class='line'>SQL> <span class="k">select </span>TABLESPACE_NAME,STATUS from dba_tablespaces;
</span><span class='line'>
</span><span class='line'>TABLESPACE_NAME STATUS
</span><span class='line'>------------------------------ ---------
</span><span class='line'>SYSTEM ONLINE
</span><span class='line'>SYSAUX ONLINE
</span><span class='line'>UNDOTBS1 ONLINE
</span><span class='line'>TEMP ONLINE
</span><span class='line'>USERS ONLINE
</span><span class='line'>TS_EXAMPLE ONLINE
</span><span class='line'>TS_FBDA ONLINE
</span><span class='line'>TBS_HIS READ ONLY
</span><span class='line'>TBS_HIS_IDX READ ONLY
</span><span class='line'>
</span><span class='line'>9 rows selected.
</span><span class='line'>
</span><span class='line'><span class="nv">$ </span> expdp <span class="se">\'</span>/ as sysdba<span class="se">\'</span> <span class="nv">dumpfile</span><span class="o">=</span>mytab.dmp <span class="nv">directory</span><span class="o">=</span>data_pump_dir <span class="nv">transport_tablespaces</span><span class="o">=</span>TBS_HIS_IDX,TBS_HIS
</span><span class='line'>
</span><span class='line'><span class="nv">logfile</span><span class="o">=</span>data_pump_dir:mytab.log
</span><span class='line'>
</span><span class='line'>Export: Release 11.2.0.1.0 - Production on Fri Oct 26 22:12:34 2012
</span><span class='line'>
</span><span class='line'>Copyright <span class="o">(</span>c<span class="o">)</span> 1982, 2009, Oracle and/or its affiliates. All rights reserved.
</span><span class='line'>
</span><span class='line'>Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
</span><span class='line'>With the Partitioning, Automatic Storage Management, Oracle Label Security, OLAP,
</span><span class='line'>Data Mining and Real Application Testing options