faqts : Computers : Databases : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 10 people (60%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

Database: MySql: Command: Multiple: Execute: How to: How to run pipe commands in MySql?

Jul 6th, 2008 13:23
Knud van Eeden, dman,


----------------------------------------------------------------------
--- Knud van Eeden --- 22 May 2005 - 02:03 am ------------------------

Database: MySql: Command: Multiple: Execute: How to: How to run pipe 
commands in MySql?

---

Steps: Overview:

 1. -Create a file containing your SQL commands
     (you will not see the SQL query text while they are executed)

e.g.

--- cut here: begin --------------------------------------------------

CREATE DATABASE databaseTest;

USE databaseTest;

CREATE TABLE
 tableCustomer
(
 columnId INT NOT NULL PRIMARY KEY,
 columnName VARCHAR( 50 )
)
;

INSERT INTO
 tableCustomer
(
 columnName
)
VALUES
(
 "Knud"
)
;

--- cut here: end ----------------------------------------------------

 2. -Save this file

      e.g. save as

       yourfilename.txt

 3. -Start MySql

 4. -Run mysql.exe by typing

      mysql.exe < yourinputfilename.txt

 5. -That will pipe this text into mysql.exe, which
     will execute it

 6. -If you want to also output the result into a file,
     from the command line, use

      mysql.exe < yourinputfilename.txt  > youroutputfilename.txt

     ---

     Note:

     This gives a possibility to automate, e.g. by using
     this commands in an MSDOS batch file.

---
---

Internet: see also:

---

Database: MySql: Command: Multiple: Execute: How to execute multiple 
commands at once in MySql?
http://www.faqts.com/knowledge_base/view.phtml/aid/36416/fid/52

----------------------------------------------------------------------