POUWIEL|COM

JeroenPouwiel

Some PostgreSQL scripthingie

DO $$
  DECLARE
    i_lower integer;
    i_upper integer;
  BEGIN
    SELECT MAX(a)+1, MAX(a)+10 INTO i_lower, i_upper FROM blaat;
    FOR r in i_lower..i_upper LOOP
      INSERT INTO blaat (a, b) (SELECT r,
                                       ARRAY_TO_STRING(ARRAY
                                                            (SELECT SUBSTR('ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
                                                                           ((RANDOM()*(36-1)+1)::INTEGER),
                                                                           1)
                                                               FROM generate_series(1,10)
                                                            ),
                                                            ''
                                                      )
                               );
    END LOOP;
  END;
$$;

That makes it go from:

a | b
----+------------
1 | Z7RGBNIN26
2 | D8QZ8ROZS2
3 | 6EUK0P5KKZ
4 | 719OWTTWVY
5 | 1LBXB8RSGB
6 | YA6O7HTATW
7 | 5UXAPFA478
8 | W4135F2KEK
9 | JTJF0E93X4
10 | FV5S9DYH1G
(10 rows)
to:

a | b
----+------------
1 | Z7RGBNIN26
2 | D8QZ8ROZS2
3 | 6EUK0P5KKZ
4 | 719OWTTWVY
5 | 1LBXB8RSGB
6 | YA6O7HTATW
7 | 5UXAPFA478
8 | W4135F2KEK
9 | JTJF0E93X4
10 | FV5S9DYH1G
11 | GXK0F55EDR
12 | WT4P0F7M1X
13 | SKTP3N3HQY
14 | JEPO605JVM
15 | E62FCTMMV3
16 | B0MH3CWSHJ
17 | X0PYJ6KMGU
18 | RNB6NYQ80I
19 | IWU70W3GC7
20 | FFUB3JT131
(20 rows)

Adding new disks to Solaris 11.4

root@rffmora01:~# format
    Searching for disks...done
    
    AVAILABLE DISK SELECTIONS:
           0. c1t0d0 <VMware-Virtual disk-2.0-24.00GB>
              /pci@0,0/pci15ad,1976@10/sd@0,0
           1. c1t1d0 <VMware-Virtual disk-2.0-32.00GB>
              /pci@0,0/pci15ad,1976@10/sd@1,0
           2. c1t2d0 <VMware-Virtual disk-2.0-32.00GB>
              /pci@0,0/pci15ad,1976@10/sd@2,0
           3. c1t3d0 <VMware-Virtual disk-2.0-32.00GB>
              /pci@0,0/pci15ad,1976@10/sd@3,0
    Specify disk (enter its number): 1
    selecting c1t1d0 <VMware-Virtual disk-2.0 cyl 4175 alt 2 hd 255 sec 63>
    [disk formatted]
    No Solaris fdisk partition found.
    
    FORMAT MENU:
            disk       - select a disk
            type       - select (define) a disk type
            partition  - select (define) a partition table
            current    - describe the current disk
            format     - format and analyze the disk
            fdisk      - run the fdisk program
            repair     - repair a defective sector
            label      - write label to the disk
            analyze    - surface analysis
            defect     - defect list management
            backup     - search for backup labels
            verify     - read and display labels
            inquiry    - show disk ID
            volname    - set 8-character volume name
            !<cmd>     - execute <cmd>, then return
            quit
format> fdisk
    No fdisk table exists. The default partition for the disk is:
    
      a 100% "SOLARIS System" partition
    
    Type "y" to accept the default partition,  otherwise type "n" to edit the
     partition table.
y
format> label
    Ready to label disk, continue? y
    
    format> verify
    
    Primary label contents:
    
    Volume name = <        >
    ascii name  = <DEFAULT cyl 4174 alt 2 hd 255 sec 63 cyl 4174 alt 2 hd 255 sec 63>
    pcyl        = 4176
    ncyl        = 4174
    acyl        =    2
    bcyl        =    0
    nhead       =  255
    nsect       =   63
    Part      Tag    Flag     Cylinders        Size            Blocks
      0 unassigned    wm       0               0         (0/0/0)           0
      1 unassigned    wm       0               0         (0/0/0)           0
      2     backup    wu       0 - 4173       31.97GB    (4174/0/0) 67055310
      3 unassigned    wm       0               0         (0/0/0)           0
      4 unassigned    wm       0               0         (0/0/0)           0
      5 unassigned    wm       0               0         (0/0/0)           0
      6 unassigned    wm       0               0         (0/0/0)           0
      7 unassigned    wm       0               0         (0/0/0)           0
      8       boot    wu       0 -    0        7.84MB    (1/0/0)       16065
      9 unassigned    wm       0               0         (0/0/0)           0
    
    format> quit
    root@rffmora01:~# format
    Searching for disks...done
    
    
    AVAILABLE DISK SELECTIONS:
           0. c1t0d0 <VMware-Virtual disk-2.0-24.00GB>
              /pci@0,0/pci15ad,1976@10/sd@0,0
           1. c1t1d0 <VMware-Virtual disk-2.0-32.00GB>
              /pci@0,0/pci15ad,1976@10/sd@1,0
           2. c1t2d0 <VMware-Virtual disk-2.0-32.00GB>
              /pci@0,0/pci15ad,1976@10/sd@2,0
           3. c1t3d0 <VMware-Virtual disk-2.0-32.00GB>
              /pci@0,0/pci15ad,1976@10/sd@3,0
Specify disk (enter its number): 1
    selecting c1t1d0 <VMware-Virtual disk-2.0 cyl 4174 alt 2 hd 255 sec 63>
    [disk formatted]
    
    
    FORMAT MENU:
            disk       - select a disk
            type       - select (define) a disk type
            partition  - select (define) a partition table
            current    - describe the current disk
            format     - format and analyze the disk
            fdisk      - run the fdisk program
            repair     - repair a defective sector
            label      - write label to the disk
            analyze    - surface analysis
            defect     - defect list management
            backup     - search for backup labels
            verify     - read and display labels
            inquiry    - show disk ID
            volname    - set 8-character volume name
            !<cmd>     - execute <cmd>, then return
            quit
format> partition
    
    PARTITION MENU:
            0      - change `0' partition
            1      - change `1' partition
            2      - change `2' partition
            3      - change `3' partition
            4      - change `4' partition
            5      - change `5' partition
            6      - change `6' partition
            7      - change `7' partition
            select - select a predefined table
            modify - modify a predefined partition table
            name   - name the current table
            print  - display the current table
            label  - write partition map and label to the disk
            !<cmd> - execute <cmd>, then return
            quit
partition> print
    Current partition table (original):
    Total disk cylinders available: 4174 + 2 (reserved cylinders)
    
    Part      Tag    Flag     Cylinders        Size            Blocks
      0 unassigned    wm       0               0         (0/0/0)           0
      1 unassigned    wm       0               0         (0/0/0)           0
      2     backup    wu       0 - 4173       31.97GB    (4174/0/0) 67055310
      3 unassigned    wm       0               0         (0/0/0)           0
      4 unassigned    wm       0               0         (0/0/0)           0
      5 unassigned    wm       0               0         (0/0/0)           0
      6 unassigned    wm       0               0         (0/0/0)           0
      7 unassigned    wm       0               0         (0/0/0)           0
      8       boot    wu       0 -    0        7.84MB    (1/0/0)       16065
      9 unassigned    wm       0               0         (0/0/0)           0
    
partition> quit
format> quit
root@rffmora01:~# prtvtoc /dev/rdsk/c1t1d0s0
    * /dev/rdsk/c1t1d0s0 partition map
    *
    * Dimensions:
    *     512 bytes/sector
    *      63 sectors/track
    *     255 tracks/cylinder
    *   16065 sectors/cylinder
    *    4176 cylinders
    *    4174 accessible cylinders
    *
    * Flags:
    *   1: unmountable
    *  10: read-only
    *
    * Unallocated space:
    *       First     Sector    Last
    *       Sector     Count    Sector
    *       16065  67039245  67055309
    *
    *                          First     Sector    Last
    * Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
           2      5    01          0  67055310  67055309
           8      1    01          0     16065     16064
root@rffmora01:~# newfs /dev/rdsk/c1t1d0s2
    newfs: construct a new file system /dev/rdsk/c1t1d0s2: (y/n)? y
    Warning: 306 sector(s) in last cylinder unallocated
    /dev/rdsk/c1t1d0s2:     67055310 sectors in 10914 cylinders of 48 tracks, 128 sectors
            32741.9MB in 683 cyl groups (16 c/g, 48.00MB/g, 5824 i/g)
    super-block backups (for fsck -F ufs -o b=#) at:
     32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
    Initializing cylinder groups:
    .............
    super-block backups for last 10 cylinder groups at:
     66162848, 66261280, 66359712, 66458144, 66556576, 66655008, 66753440,
     66851872, 66950304, 67048736
root@rffmora01:/ora# mount /dev/dsk/c1t1d0s2 /ora/product
root@rffmora01:/ora# cat /etc/vfstab
    #device         device          mount           FS      fsck    mount   mount
    #to mount       to fsck         point           type    pass    at boot options
    #
    # START Informational entries for filesystems mounted by the kernel
    #/devices       -               /devices        devfs   -       no      -
    #/proc          -               /proc           proc    -       no      -
    #ctfs           -               /system/contract ctfs   -       no      -
    #objfs          -               /system/object  objfs   -       no      -
    #sharefs        -               /etc/dfs/sharetab       sharefs -       no      -
    #fd             -               /dev/fd         fd      -       no      -
    #swap           -               /tmp            tmpfs   -       yes     -
    # END Informational entries for filesystems mounted by the kernel
    
    /dev/zvol/dsk/rpool/swap        -               -               swap    -       no      -
    /dev/dsk/c1t1d0s2       -       /ora/product    ufs     -       yes     -

Bouwbeurs

Here we come
20150211_105710

EXP with db < 9.2.0.5 from db >= 9.2.0.5

In this particular case, I was trying to export from a 10.2.0.4 db with exp from 8.1.7.4.
The schema in question had (several) lobsegments, which would trigger Oracle bug 3784697.

Summary Bug report:

Bug 3784697: EXPORT OF LOB FROM 9205 WITH PRE-9205 EXP GIVES EXP-3 (NO STORAGE DEF FOUND) Read the rest of this entry »

RoR: Rspec run 1 module

To run just one module:
rspec spec/models/user_spec.rb -e “should have an encrypted password attribute”

VI: search & replace

Generally I use:

:%s/search/replace/g

This page shows the means of inserting a character at the beginning of each line:

:14,20s/^/#/

Categories