Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts

2022-02-10

Oracle select multi rows random

 

select B.*, to_char(B.Rand, '0XXXXX') Str from

(

 select A.*, trunc(DBMS_RANDOM.value(A.L, A.H)) Rand from

 (

   select level no,

      200000+level*100000 L,

      200000+level*100000+50000 H

   from dual connect by level <= 100

 ) A

) B

;


NO     L        H       RAND STR
---------- ---------- ---------- ---------- -------
1     300000   350000     317314  04D782
2     400000   450000     408319  063AFF
3     500000   550000     538362  0836FA
4     600000   650000     633656  09AB38
5     700000   750000     724852  0B0F74
6     800000   850000     823489  0C90C1
7     900000   950000     948578  0E7962
8    1000000 1050000    1026192  0FA890
9    1100000 1150000    1107769  10E739
10    1200000 1250000    1221980  12A55C
11    1300000 1350000    1338767  146D8F
12    1400000 1450000    1418473  15A4E9
13    1500000 1550000    1522499  173B43
14    1600000 1650000    1646482  191F92
15    1700000 1750000    1746193  1AA511
16    1800000 1850000    1815369  1BB349
17    1900000 1950000    1923534  1D59CE
18    2000000 2050000    2030796  1EFCCC
19    2100000 2150000    2149042  20CAB2
20    2200000 2250000    2202140  219A1C


2014-04-02

tiny core linux Oracle XE 11R2


SWAP=/mnt/sda1/tmp/swap
MEM=1G

####################################
# load util

st2 glib2 make gcc libaio binutils net-tools
st2 bash sed
st2 bzip2-lib
sudo ln -s /usr/local/lib/libbz2.so /usr/local/lib/libbz2.so.1
sudo ln -s /usr/bin/awk /bin


####################################
# add lib path

sudo ln -s /lib /lib64
#sudo ln -s /usr/local/lib /usr/local/lib64
#sudo ln -s /usr/lib /usr/lib64
#sudo ln -s /var/lib /var/lib64

#echo /u01/app/oracle/product/11.2.0/xe/lib | sudo tee -a /etc/ld.so.conf
#sudo ldconfig


####################################
# Create User oracle:dba

sudo addgroup dba
sudo adduser -D oracle -G dba

sudo passwd -d oracle

echo "
ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe

LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/usr/local/lib:\$ORACLE_HOME/lib
export LD_LIBRARY_PATH

PATH=\$PATH:/usr/local/bin
export PATH

. $ORACLE_HOME/bin/oracle_env.sh
" | sudo tee -a /home/oracle/.ashrc


####################################
#  install RPM

sudo rpm -i Disk1/oracle-xe-11.2.0-1.0.x86_64.rpm


####################################
#  Create Folder ??

sudo mkdir -p /var/lock/subsys
#sudo mkdir -p /u01/app/oracle/oradata
#sudo mkdir -p /u01/app/oracle/diag
sudo mkdir -p /u01/app/oracle/product/11.2.0/xe/config/log
sudo mkdir -p /u01/app/oracle/product/11.2.0/xe/config/seeddb


####################################
# fix script executable

sudo chmod a+x /u01/app/oracle/product/11.2.0/xe/config/scripts/*.sh
sudo chmod a+x /etc/init.d/oracle-xe

sudo ln -s /u01/app/oracle/product/11.2.0/xe/lib/libagtsh.so.1.0 /u01/app/oracle/product/11.2.0/xe/lib/libagtsh.so


####################################
# change owner to oracle:dba

sudo chown -R oracle:dba /u01


####################################
# set memory

sudo sed -i -e "s/%memory_target%/${MEM}/" /u01/app/oracle/product/11.2.0/xe/config/scripts/init.ora
sudo sed -i -e "s/%memory_target%/${MEM}/" /u01/app/oracle/product/11.2.0/xe/config/scripts/initXETemp.ora


####################################
# set swap

#mkswap $SWAP
sudo swapon $SWAP


####################################
# change kernel setting

echo "250 32000 100 128" | sudo tee /proc/sys/kernel/sem
echo "4294967295" |sudo tee /proc/sys/kernel/shmmax
echo "4096" | sudo tee /proc/sys/kernel/shmmni
echo "2097152" | sudo tee /proc/sys/kernel/shmall
echo "6815744" | sudo tee /proc/sys/fs/file-max
echo "9000 65500" | sudo tee /proc/sys/net/ipv4/ip_local_port_range

cat /proc/sys/kernel/sem \
/proc/sys/kernel/shmmax \
/proc/sys/kernel/shmmni \
/proc/sys/kernel/shmall \
/proc/sys/fs/file-max \
/proc/sys/net/ipv4/ip_local_port_range


####################################
# configure oracle

sudo /etc/init.d/oracle-xe status

sudo /etc/init.d/oracle-xe configure

sudo /etc/init.d/oracle-xe status

# sudo /etc/init.d/oracle-xe start


####################################
# login

# sqlplus system


####################################
# set for remote login

# SQL> EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);