Showing posts with label export command. Show all posts
Showing posts with label export command. Show all posts

Thursday, March 3, 2016

Database export and import commands for command prompt

Export/Import the dump commands for MySQL, Oracle and MS SQL

The dump will be created with log file.

MySQL
cd "C:\Program Files\MySQL\MySQL Server 5.6\bin"
mysql -h localhost -p1234 -u root app301 < "D:\app1_bak.sql" >> mysqldump.log 2>&1

mysql -h localhost -p1234 -u root app301 < "D:\app1_bak.sql" >> mysqldump.log 2>&1

ORACLE
sql>exp oraproj/log@orcl11g file=D:\oradump.dmp full=y

sql>expdp oraproj/log@orcl11g file=D:\oradump.dmp full=y

To Create the schema
sql>create user app301 identified by log;
sql>grant dba  to app301;

Import syntax for Oracle db
imp SchemaName/Pwd@orcl file=D:\oradump12.dmp full=y log=D:\oralog.txt;

For Oracle 11g db
sql>create directory import as 'D:\';
sql>grant read,write on directory import to app301;
sql>impdp dileep/pwd directory=your_exp_dir file=dileep.dmp remap_schema=dileep:kumar



MS SQL
sqlcmd -E -S MYSYSTEM\SQLEXPRESS -Q "BACKUP DATABASE V95 TO DISK='D:\mssqldump.bak'"

SQLCMD -U %1 -P %2 -S %3 -Q "RESTORE DATABASE %4 FROM DISK='%5' WITH RECOVERY, REPLACE, MOVE '%6' TO '%7.mdf', MOVE '%6_log' TO '%7_log.ldf'" -o %8

or
SQLCMD -E -S MYSYSTEM\SQLEXPRESS -Q "RESTORE DATABASE app301 FROM DISK='D:\mssqldump.bak'"

or
sqlcmd -S mysystem\sqlexpress -U sa -P pwd

RESTORE DATABASE app301 FROM DISK='D:\mssqldump.bak' WITH RECOVERY, REPLACE, MOVE 'OldSchema' TO 'C:\data\app301.mdf', MOVE 'OldSchema_log' TO 'C:\data\app301_log.ldf';
go

SQLCMD-S MYSYSTEM\SQLEXPRESS -E -Q "RESTORE DATABASE app301 FROM DISK='D:\mssqldump.bak' WITH RECOVERY, REPLACE, MOVE 'v95' TO 'C:\data\app301.mdf', MOVE 'v95_log' TO 'C:\data\app301_log.ldf'" -o D:\TEST.TXT

Execute the following script in SQL editor,
RESTORE DATABASE app301 FROM DISK='D:\mssqldump.bak' WITH  FILE = 1, MOVE N'app301' TO N'C:\data\app301.mdf', MOVE N'app301_log' TO N'C:\data\app301_log.ldf', NORECOVERY,  NOUNLOAD,  STATS = 10


The below is the example to remap the schema for MS SQL db.
CREATE SCHEMA app301;
ALTER SCHEMA app301 TRANSFER app300.AxEmpMaster;
(It will change the schema name of AxEmpMaster object from app300 schema to app301 schema).

Delphi Thread Example

Delphi Thread Example Threads mean a lot with the latest computer technology. They allow you to perform multiple tasks at the same time ...