me,myself,english and programming..

Archive for the ‘Database’ Category

MySQL + Solution for SELECT INTO

Sunday, June 10th, 2012

MySQL Server doesn’t support the SELECT INTO TABLE syntax. Instead, MySQL Server supports the INSERT INTO … SELECT. Below syntax is equivalent with SELECT INTO in MySQL.

CREATE TABLE mynewtable (
SELECT f2,f3,f4 from tableA,tableB
where tableA.f1 = tableB.f1
);

Hope it helps,

Till then…adioss

Script to backup MySQL from server and dump to localhost

Tuesday, August 16th, 2011

As a programmer, you will always find a way how to automate your task right ? do you ?

Well, this is my script to get the latest copy of mysql database into my local pc.

@Echo off
echo [%date% %time%] Starting backup...
mysqldump -u root -h 192.168.1.80 -pmyrootpwd mysqldb > mysqldb.sql
echo [%date% %time%] Starting dump....
mysql -u root -h localhost -pmyrootpwd mysqldb < mysqldb.sql
echo [%date% %time%] done.
pause

Save it as a batch file and just double click to run it. Your output will be something like below.

backup-restore-batch

 

Thats all. Hope it helps.

Execute SQL Server 2008 R2 stored procedure using command line

Monday, July 25th, 2011

Using sqlcmd command from command line, you can connect to your sql server engine.

Below is my sample stored procedure running from command line.

2011-07-25 181950

 

p/s: semakin hari aku semakin malas utk update blog. harap maklum.

Oracle High Availability JDBC Connection String

Saturday, April 10th, 2010

I’m finally successfully configure my apps to connect to Oracle RAC.

As for my reference later, here is the connection string.

(DESCRIPTION_LIST=
(FAILOVER=true)
(LOAD_BALANCE=true)
(DESCRIPTION=
(ADDRESS= (PROTOCOL=TCP) (HOST=server1) (PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=orcl))
)
(DESCRIPTION=
(ADDRESS= (PROTOCOL=TCP) (HOST=server2) (PORT=1521))
(CONNECT_DATA=
(SERVICE_NAME=orcl))
)
)

JDBC URL will be something like this

jdbc:oracle:thin:@(DESCRIPTION_LIST…)

Error: ORA-01033 ORACLE initialization or shutdown in progress

Thursday, March 11th, 2010

For some reason which I don’t know why, my oracle give me that kind of error.

Googling give me for below solution. And here I post for my future reference, and also for you if you got this same problem . ;)

Run this command first in console.

sqlplus /nolog

And after that, use these commands :

SQL> connect / as sysdba
Connected.
SQL> shutdown abort
ORACLE instance shut down
SQL> startup nomount
ORACLE instance started.
SQL> alter database mount;
SQL> alter database open;

(more…)