scratchpad
if you need to APPEND output of watch to a FILE you can do it in this way:
1) create file with cmd to execute
for ex:
date '+%F %T' | tr -d '\n\r' && echo -n ' === ' && ping -c 1 localhost|grep icmp_req
2) execute watch -n 5 --no-title "sh script.sh >> file_append.txt"
==================
#
# script : blocker_alert_rac.sh
# Purpose : Monitoring blockers in RAC env which hold lock more than 10 min or
# there are > 10 blockers/waiters sessions
#
# Notes :
# In RAC, a blocker can block a session in the local nodes as well as
# sessions in other nodes
#
# Modifications
# Name MM-DD-YYYY Desc
# Denis 06-19-2014 Created
#
if [ $# -ne 1 ]; then
echo; echo "Usage: blocker_alert_rac.sh <ORACLE_SID>"
exit 1
fi
. ~/.currentenv
export ORACLE_SID=$1
SCRIPTDIR=`dirname $0`
LOGFILE=/tmp/blockers.txt
NOTIFY_LIST='cmb-ops-oracle-dba-irs@verizon.com'
#NOTIFY_LIST='yu.d.sun@verizon.com'
TSTAMP=`date +%m%d_%H%M`
ALERT="NO"
MAXMIN=0
sqlplus -s / <<EOF
set trimspool on feedback off verify off echo off
spool $LOGFILE
rem use in rac database
rem Display all sessions holding or requesting lock of
rem resource some session is waiting for. Waiting session has non-zero value of column
rem GV$LOCK.REQUEST. Resource is identified by (TYPE,ID1,ID2 columns of GV$LOCK view).
rem
rem ref:Detecting Blocking Sessions in RAC and non-RAC (Enqueue Locks) Environments [ID 398519.1]
set pagesize 90
set linesize 150
set echo off
col BLOCK for 9
col LMODE for 9
col INST_ID for 9
col REQUEST for 9
col SID for 999999
col username for a12
col timeheld format 999999 heading "Time Held|(min)"
col block format a5 heading "Block"
col blocking_instance format 99 heading "Blking|Inst_ID"
col blocking_session format 99999 heading "Blking|SID"
select
l.INST_ID,
l.SID,
s.serial#,
s.username,
l.TYPE,
decode(l.lmode,0,'None',1,'Null',2,'Row-S',3,'Row-X',4,'Share',5,'S/Row-X',6,'Exclusive') lockheld,
DECODE(REQUEST,0,'None',1,'Null',2,'Row-S',3,'Row-X',4,'Share', 5,'S/ROW',6,'Exclusive')REQUEST,
CTIME/60 timeheld ,
decode(l.BLOCK,0,'No',1, 'Yes', 2, 'Yes') block,
s.blocking_instance,
s.blocking_session
from gv\$lock l,
gv\$session s
where (l.ID1,l.ID2,l.TYPE) in
(select ID1,ID2,TYPE
from gv\$lock where request>0)
and l.sid=s.sid
and l.inst_id=s.inst_id
order by l.id1, l.lmode desc, l.ctime desc
;
spool off
exit
EOF
cat $LOGFILE
LNCNT=`wc -l $LOGFILE | awk '{print $1}'`
echo "LNCNT=$LNCNT"
# Determine whether alert is needed
# if there are > 17 sessions in block/wait or blocker hold lock > 10 min
# we will alert
if ((LNCNT > 20))
then
ALERT="YES"
else
for i in `cat $LOGFILE | awk '{ if ( $0 ~ /Yes/ ) { print $8 } }'`
do
if (( $i > $MAXMIN))
then
MAXMIN=$i
fi
done
echo "MAXMIN=$MAXMIN"
if ((MAXMIN >=10 ))
then
ALERT="YES"
fi
fi
echo "ALERT=$ALERT"
# SIDS or SIDS2 too long ( > 240 charater) there will have error need to fix this in the future
if [[ $ALERT == "YES" ]]
then
# get the sqls that blocked sessions are executiing
sqlplus -s / <<EOF
set lines 200 pages 9999 head on
col sqltext format a50
spool /tmp/blked_sqltxt.txt
pro
pro
pro =================================================
pro blocked sessions are running the following sqls:
pro =================================================
select gs.inst_id, gs.sid, gs.sql_id, substr(ga.sql_text, 1,200) sqltext from
gv\$session gs,
gv\$sqlarea ga
where gs.event = 'enq: TX - row lock contention'
and gs.sql_id=ga.sql_id
and gs.inst_id=ga.inst_id
;
spool off
exit
EOF
cat $LOGFILE /tmp/blked_sqltxt.txt > /tmp/blocker_alert_rac_msg.txt
echo "send email"
mailx -s "ORACLE ALERT: `hostname` dangerous blockers alert!" ${NOTIFY_LIST} < /tmp/blocker_alert_rac_msg.txt
# cp /tmp/blocker_alert.txt $LOGDIR/blocker_alert_$TSTAMP.log
fi
===========================================================
import boto3
s3 = boto3.resource('s3')
TARGETBUCKET='west-test-bucket'
def handler(event, context):
for record in event['Records']:
bucket = record['s3']['bucket']['name']
key = record['s3']['object']['key']
copy_source = {
'Bucket': bucket,
'Key': key
}
s3.meta.client.copy(copy_source, TARGETBUCKET, key)
===================================================================
celscplpd001:/opt/oracle/product/admin/omrdb/scripts [omrdb1] $ cat chk_dg_log_apply.sh
#!/usr/bin/ksh
. ~/.profile
NOTIFY=yu.d.sun@verizon.com;cmb.ops.oracle.dba.irs@verizon.com
echo "run query"
sqlplus -s / <<ENDSQL
spool /tmp/chk_dg_log_apply.log
-- run at primary site
-- assume DEST_ID =2 based on the LOG_ARCHIVE_DEST_n
-- output if the archive log GAP is more than 5 then it returns status as Error
-- and if the Archive GAP is less than 5 the status will be returned as OK
--
column applied_time for a30
set linesize 140
select to_char(sysdate,'mm-dd-yyyy hh24:mi:ss') "Current Time" from dual;
SELECT DB_NAME, APPLIED_TIME, LOG_ARCHIVED-LOG_APPLIED LOG_GAP ,
(case when ((APPLIED_TIME is not null and (LOG_ARCHIVED-LOG_APPLIED) is null) or
(APPLIED_TIME is null and (LOG_ARCHIVED-LOG_APPLIED) is not null) or
((LOG_ARCHIVED-LOG_APPLIED) > 5))
then 'Error! Log Gap is '
else 'OK!'
end) Status
FROM
(
SELECT INSTANCE_NAME DB_NAME
FROM GV\$INSTANCE
where INST_ID = 1
),
(
SELECT MAX(SEQUENCE#) LOG_ARCHIVED
FROM V\$ARCHIVED_LOG WHERE DEST_ID=1 AND ARCHIVED='YES' and THREAD#=1
),
(
SELECT MAX(SEQUENCE#) LOG_APPLIED
FROM V\$ARCHIVED_LOG WHERE DEST_ID=2 AND APPLIED='YES' and THREAD#=1
),
(
SELECT TO_CHAR(MAX(COMPLETION_TIME),'DD-MON/HH24:MI') APPLIED_TIME
FROM V\$ARCHIVED_LOG WHERE DEST_ID=2 AND APPLIED='YES' and THREAD#=1
)
UNION
SELECT DB_NAME, APPLIED_TIME, LOG_ARCHIVED-LOG_APPLIED LOG_GAP,
(case when ((APPLIED_TIME is not null and (LOG_ARCHIVED-LOG_APPLIED) is null) or
(APPLIED_TIME is null and (LOG_ARCHIVED-LOG_APPLIED) is not null) or
((LOG_ARCHIVED-LOG_APPLIED) > 5))
then 'Error! Log Gap is '
else 'OK!'
end) Status
from (
SELECT INSTANCE_NAME DB_NAME
FROM GV\$INSTANCE
where INST_ID = 2
),
(
SELECT MAX(SEQUENCE#) LOG_ARCHIVED
FROM V\$ARCHIVED_LOG WHERE DEST_ID=1 AND ARCHIVED='YES' and THREAD#=2
),
(
SELECT MAX(SEQUENCE#) LOG_APPLIED
FROM V\$ARCHIVED_LOG WHERE DEST_ID=2 AND APPLIED='YES' and THREAD#=2
),
(
SELECT TO_CHAR(MAX(COMPLETION_TIME),'DD-MON/HH24:MI') APPLIED_TIME
FROM V\$ARCHIVED_LOG WHERE DEST_ID=2 AND APPLIED='YES' and THREAD#=2
)
/
spool off
exit
ENDSQL
COUNTOK=`cat /tmp/chk_dg_log_apply.log | grep "OK" | wc -l`
echo "c=$COUNTOK"
if [ $COUNTOK -lt 2 ]
then
mailx -s "`hostname` alert Data Guard apply log gap > 5 " $NOTIFY < /tmp/chk_dg_log_apply.log
fi
===============
celttplpd001:/tmp [omrdb1] $ cat chk_dg_status.sh
#!/bin/ksh
# chk_dg_status.sh rn very 15 min
#
#
. ~/.profile
NOTIFY='yu.d.sun@verizon.com,cmb.ops.oracle.dba.irs@verizon.com'
sqlplus / as sysdba << EOF
set term off verify off echo off feedback off
set pagesize 0 linesize 200
set space 0
set echo off
spool /tmp/chk_dg_status.txt
select 'ALERT ' || to_char(timestamp,'YYYY-MM-DD HH24:MI:SS ') || inst_id || ' ' || message
from gv\$dataguard_status
where severity in ('Error','Fatal')
and timestamp > sysdate - 15/1440
order by timestamp;
spool off
exit;
EOF
if [[ -n `grep -i "^ALERT" /tmp/chk_dg_status.txt ` ]];
then
echo "error"
mailx -s "Dataguard status error - `hostname` " $NOTIFY < /tmp/chk_dg_status.txt
fi
==== dg ===
#!/bin/ksh
# chk_dg_status.sh rn very 15 min
#
#
. ~/.profile
NOTIFY='yu.d.sun@verizon.com,cmb.ops.oracle.dba.irs@verizon.com'
sqlplus / as sysdba << EOF
set term off verify off echo off feedback off
set pagesize 0 linesize 200
set space 0
set echo off
spool /tmp/chk_dg_status.txt
select 'ALERT ' || to_char(timestamp,'YYYY-MM-DD HH24:MI:SS ') || inst_id || ' ' || message
from gv\$dataguard_status
where severity in ('Error','Fatal')
and timestamp > sysdate - 15/1440
order by timestamp;
spool off
exit;
EOF
if [[ -n `grep -i "^ALERT" /tmp/chk_dg_status.txt ` ]];
then
echo "error"
mailx -s "Dataguard status error - `hostname` " $NOTIFY < /tmp/chk_dg_status.txt
fi
=== switch over
ref : 12c Dataguard Switchover Best Practices using DGMGRL(Dataguard Broker Command Prompt) (Doc ID 1582837.1)
-- check rac standby db log recived and applied
select thread#, max(sequence#) "Last Standby Seq Received"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
group by thread# order by 1;
select thread#, max(sequence#) "Last Standby Seq Applied"
from v$archived_log val, v$database vdb
where val.resetlogs_change# = vdb.resetlogs_change#
and val.applied in ('YES','IN-MEMORY')
group by thread# order by 1;
=======================================
echo " " > scp_ets.log
echo "###### scp started `date` #######" >> scp_ets.log
scp dbaets.dmp spffdpd1:/apps/opt/oracle/admin/codedrop/dbaets/expdump >> scp_ets.log
echo "SCP_EXIT_STATUS-$?" >> scp_ets.log
scp flow_comp.dmp spffdpd1:/apps/opt/oracle/admin/codedrop/dbaets/expdump >> scp_ets.log
echo "SCP_EXIT_STATUS-$?" >> scp_ets.log
scp flow_file_obj.dmp spffdpd1:/apps/opt/oracle/admin/codedrop/dbaets/expdump >> scp_ets.log
echo "SCP_EXIT_STATUS-$?" >> scp_ets.log
scp *.sh spffdpd1:/apps/opt/oracle/admin/codedrop/dbaets/expdump >> scp_ets.log
echo "SCP_EXIT_STATUS-$?" >> scp_ets.log
check=`grep "SCP_EXIT_STATUS-0" scp_ets.log | wc -l`
echo $check
if [[ $check -ne 4 ]]; then
mailx -s "`hostname` - $0 scp error check with Denis !" cmb.ops.oracle.dba.irs@verizon.com
fi
cat *.log | mailx -s "`hostname` - etsdb export job status" yu.d.sun@verizon.com
================================
#export PATH=.:"C:\\Program Files\\Vim\\vim73":C:\\xampp\\mysql\\bin:C:\\oraclexe\\app\\oracle\\product\\11.2.0\\server\\bin:$PATH
#export PATH="C:\\gnuplot\\bin":$PATH
export PATH="C:\\Program Files\\Amazon\\AWSCLI":$PATH
export NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'
export SQLPATH='c:\\Denis_files\\ORACLE\\scripts_oracle'
export TNS_ADMIN=c:\\Denis_files\\VZ2009\\tns
alias tns=' vi /cygdrive/c/Denis_files/VZ2009/tns/tnsnames.ora '
alias vz=' cd /cygdrive/c/Denis_files/VZ2009 '
alias script=' cd /cygdrive/c/Denis_files/ORACLE/scripts_oracle '
alias prac=' cd /cygdrive/c/Denis_files/ORACLE/Practise_Oracle '
alias doc1=' cd /cygdrive/c/Denis_files/ORACLE/Practise_Oracle/htmldocs '
alias doc2=' cd /cygdrive/c/inetpub/wwwroot/Sites/dbadocs/DBAHANDBOOK_SSP_ORDERS '
alias awswd=' cd /cygdrive/c/Denis_files/ORACLE/DBAKnowlegeBase/AWS_AMAZON '
alias sqlp='rlwrap -D2 -irc -b'\''"@(){}[],+=&^%#;|\'\'' -f /home/v983294//wordfile_11gR2.txt sqlplus'
export MYSQL_PS1="\u@\h [\d]>
============================
celttplpd001:/opt/oracle/product/admin/omrdb/scripts [omrdb1] $ cat rman_level_0.rcv
run {
allocate channel d1 type disk format '/backup01/rman/rman_level0_%d_%p_%s_%t';
allocate channel d2 type disk format '/backup01/rman/rman_level0_%d_%p_%s_%t';
backup incremental level=0 maxsetsize 35G database tag 'level0_backup';
backup archivelog until time 'sysdate - 7' delete input;
crosscheck backup;
delete obsolete recovery window of 3 days;
delete expired backup;
resync catalog;
release channel d1;
release channel d2;
}
celttplpd001:/opt/oracle/product/admin/omrdb/scripts [omrdb1] $ cat rman_level_0.sh
#!/bin/ksh
. ~/.profile
CURRDIR=/opt/oracle/product/admin/omrdb/scripts
LOGDATE=`date +\%a`
LOGFILE=$CURRDIR/log/rman_level_0_${LOGDATE}.log
NOTIFY=yu.d.sun@verizon.com
cd $CURRDIR
$ORACLE_HOME/bin/rman target / catalog rman/rman@dbahrgrd cmdfile=rman_level_0.rcv log=${LOGFILE}
mailx -s "$0 `hostname`" $NOTIFY < $LOGFILE
=====================
begin DBMS_SCHEDULER.create_job ( job_name => 'Monitor_Tablespace', job_type => 'PLSQL_BLOCK', job_action => 'BEGIN db_admin.proactive.check_tablespace; END;', start_date => trunc(sysdate, 'HH24'), repeat_interval => 'freq=hourly; byminute=0,20,40', end_date => NULL, enabled => TRUE ); end; /
----========================= check alert log script
#!/usr/bin/ksh
#
# Copyright (c) 2014 Verizon. All rights reserved.
#
# NAME
# chk_alert_log.sh
#
# DESCRIPTION
# To report any error generated in the alert log file
#
# NOTES
# Frequency : Every 15 minutes
# a subdir log should be exist
#
# MODIFIED (MM/DD/YY)
# Denis 06/2/14 - obtain alert log location from database etc
if [ $# != 1 ]
then
echo usage: $0 ORACLE_SID
exit
fi
export ORACLE_SID=${1}
#calling the environment setting
. ~/.profile
CURR_DIR=`dirname $0`
LOG_DIR=$CURR_DIR/log
DIFF_LOG=$LOG_DIR/alert_${ORACLE_SID}_diff.log
BDUMP=/apps/opt/oracle/diag/rdbms/obilldb/obilldb/trace
MAIL_LIST="cmb-ops-oracle-dba-irs@verizon.com,yu.d.sun@verizon.com"
#MAIL_LIST="yu.d.sun@one.verizon.com"
mv $LOG_DIR/new_${ORACLE_SID}_alert.log $LOG_DIR/old_${ORACLE_SID}_alert.log
tail -2000 $BDUMP/alert_${ORACLE_SID}.log > $LOG_DIR/new_${ORACLE_SID}_alert.log
diff $LOG_DIR/new_${ORACLE_SID}_alert.log $LOG_DIR/old_${ORACLE_SID}_alert.log | grep "^<" > $DIFF_LOG
cat $DIFF_LOG|egrep "ORA-|DBA-" > $LOG_DIR/alert_ora_errors.log
msg=`cat $LOG_DIR/alert_ora_errors.log`
# send an email with attachment and with message body from a file as well
# seems extra lines for subject will go to message body
## uuencode missing
if [[ -s $LOG_DIR/alert_ora_errors.log ]]
then
( uuencode $DIFF_LOG `basename $DIFF_LOG`
) | mailx -s "`hostname`:${ORACLE_SID} ALERT_LOG Error
`echo $msg`
" ${MAIL_LIST}
fi
if [[ -s $LOG_DIR/alert_ora_errors.log ]]
then
mailx -s "`hostname`:${ORACLE_SID} ALERT_LOG Error" ${MAIL_LIST} < $LOG_DIR/alert_ora_errors.log
fi
=================================
LOAD DATA LOCAL INFILE './v_customer_attrs.txt' INTO TABLE vzw24_admin.v_customer_attrs
FIELDS TERMINATED BY '~'
-- OPTIONALLY ENCLOSED BY '"'
ESCAPED BY ''
LINES STARTING BY 'zzz'
(
customer_ref
,@first_name
,@last_name
,@middle_name
,@date_of_birth
,@ecpdid
,@mdn
,@deviceid
,@company_name
,@provision_user_id
,@account_id
,@customer_type
,@old_provision_user_id
,@old_account_id
,@vision_cust_id
,@vision_acct_id
,@is_converted_vision_acct
,@old_vision_cust_id
,@old_vision_acct_id
)
set
first_name = nullif(@first_name,'')
,last_name = nullif(@last_name,'')
,middle_name = nullif(@middle_name , '')
,date_of_birth = nullif(@date_of_birth,'')
,ecpdid = nullif(@ecpdid, '')
,mdn = nullif(@mdn, '')
,deviceid = nullif(@deviceid,'')
,company_name = nullif(@company_name, '')
,provision_user_id = nullif(@provision_user_id, '')
,account_id = nullif(@account_id,'')
,customer_type = nullif(@customer_type,'')
,old_provision_user_id = nullif(@old_provision_user_id, '')
,old_account_id = nullif(@old_account_id, '')
,vision_cust_id = nullif(@vision_cust_id, '')
,vision_acct_id = nullif(@vision_acct_id, '')
,is_converted_vision_acct = nullif(@is_converted_vision_acct,'')
,old_vision_cust_id = nullif(@old_vision_cust_id, '')
,old_vision_acct_id = nullif(@old_vision_acct_id, '')
;
show warnings;
========================
#!/bin/ksh
# name: exp_flyang.sh
#
# set up your env change to your setting
. /home/oracle/.profile_11g
CURRDIR=`dirnam $0`
cd $CURRDIR
export ORACLE_SID=hzfyskyd
# export schema
exp flyang/flyang301 file=flyang.dmp owner=flyang log=flyang.log
echo " " > scp_flyang.log
echo "###### scp started `date` #######" >> scp_flyang.log
# transfer the dump file to destination server
# change servername and folder as needed
# set up SSH between source and destination server with SSH key search ssh-keygen
#
scp flyang.dmp servername:/tmp >> scp_.log
echo "SCP_EXIT_STATUS-$?" >> scp_flyang.log
check=`grep "SCP_EXIT_STATUS-0" scp_flyang.log | wc -l`
echo $check
if [[ $check -ne 4 ]]; then
mailx -s "`hostname` - $0 scp error check with DBA !" yourname@yourcompany.com
fi
=============
===
in target database, write a script:
drop table flyange.table1;
drop table flyange.table2;
...
drop table flyange.tablen;
imp flyang/flyang301 file=flyang.dmp full=y ignore=y log=flyang_imp.log
====================
problem set up Galera cluster 10.1.9 in AWS EC2 environment
* Env: AWS EC2 Amazon Linux AMI release 2015.09
* tarball downloaded: mariadb-10.1.9-linux-glibc_214-x86_64.tar.gz
* During installation through mysql_install_db, find jemalloc required.
Downloand and installed jemalloc-3.6.0-1.el7.x86_64.rpm
* Confirmed the single MariaDB instance looks good.
* Prepared total three EC2 nodes to configure Galera Cluster
(update my.cnf with wsrep* parameters etc)
* Trying to start the cluster
./bin/mysqld_safe --defaults-file=$MYSQL_HOME/my.cnf --wsrep-new-cluster &
Reciving error message:
[ERROR] WSREP: wsrep_load(): dlopen(): libssl.so.1.0.0: cannot open shared object file: No such file or directory
[ERROR] WSREP: wsrep_load(): dlopen(): libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
Learned that libssl and libcrypto come from openssl
$ rpm -qa openssl
openssl-1.0.1k-10.87.amzn1.x86_64
* create soft links libssl.so.1.0.0 and libcrypto.so.1.0.0
pointing to libssl.so.1.0.1k and libcrypto.so.1.0.1k respectively
* Start the cluster again
Recieving error message:
[ERROR] WSREP: wsrep_load(): dlopen(): /lib64/libcrypto.so.1.0.0: version `OPENSSL_1.0.0' not found (required by /home/my sql/mariadb-10.1.9/lib/libgalera_smm.so)
[ERROR] WSREP: wsrep_load(/home/mysql/mariadb-10.1.9/lib/libgalera_smm.so) failed: Invalid argument (22). Reverting to no provider.
At this point, I am not sure what is the best action.It seems to me libalera_smm.so requires OPENSSL_1.0.0 ? Should I remove current openssl-1.0.1k-10.87.amzn1.x86_64 and try to find a openssl_1.0.0 version to install?
======================
$ sqlplus 'db_admin@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle-instance01.c4jml6dl9poq.us-east-1.rds.amazonaws.com) (PORT=1521))(CONNECT_DATA=(SID=TESTDB)))'
====================
slow_query_log = 1
slow_query_log_file = /apps/opt/mysql/db01/admin/db01_slow.log
long_query_time = 10
log_queries_not_using_indexes = 1
====
**** The sysbench OLTP benchmark
http://sgdba.blogspot.com/2014/08/sysbench-05-on-centos7.html
https://blog.mariadb.org/using-lua-enabled-sysbench/
sysbench --test=/u01/app/mysql/sysbench-0.5/sysbench/tests/db/oltp.lua --oltp-table-size=5000000 --mysql-db=test --mysql-user=root --mysql-password=wat0eR7! prepare
sysbench --test=/u01/app/mysql/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-db=test --mysql-user=root --mysql-password=wat0eR7! --num-threads=4 --max-time=30 --report-interval=5 run
sysbench --test=/u01/app/mysql/sysbench-0.5/sysbench/tests/db/oltp.lua --mysql-db=test --mysql-user=root --mysql-password=wat0eR7! --num-threads=1 --max-time=120 --report-interval=5 run
====
php
====
# cat dbconfig.php
<?php
$host = 'localhost';
$dbname = 'test';
$username = 'root';
$password = '';
# cat phpmysqlconnect.php
<?php
require_once 'dbconfig.php';
try {
$conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
echo "Connected to $dbname at $host successfully.";
} catch (PDOException $pe) {
die("Could not connect to the database $dbname :" . $pe->getMessage());
}
# cat exec_sqlfile.php
<?php
require_once 'phpmysqlconnect.php';
$sql = file_get_contents('ddl.sql');
$qr = $conn->exec($sql);
echo $qr
?>
# cat ddl.sql
create table if not exists my_tab (id int , t datetime);
insert into my_tab values (1, now());