Web lists-archives.org

RE: Some way/tool to do this with database scripts backups




Hi,

> if i have for example
> a simple table call person
> 
> with 'id' and 'name' how columns
> 
> i can do a backup and get some file (A.sql)
> with all the inserts statements
> 
> here, all fine
> 
> but
> how i can do this?

Have a look at the 'mysqldump' command line utility.
It goes something like 'mysqldump -u <user> -p <password> -h <host>
<database> [<table>] > output.sql'.
This will generate a text file with SQL statements that you can use to
recreate the table.

See http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html.

> for each insert statement generated in A.sql
> create a new B.sql, with update statements
> 
> its possible do this?

You could do this by editting the 'output.sql' file, changing the table
name from A to B.
Or you could execute the following SQL: 'CREATE TABLE B SELECT * FROM
A'. 

See http://dev.mysql.com/doc/refman/5.0/en/create-table.html.

> even worst, if a have a table with 20 columns
> i need the way to generate the same B.sql
> but with my desired columns to update

I am not sure I understand your question, but you could make a database
export using 'mysqldump', then alter the statements in the resulting
output file to create the tables you need...


HTH,

Martijn

-- 
The information contained in this communication and any attachments is confidential and may be privileged, and is for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited.  Unless explicitly stated otherwise in the body of this communication or the attachment thereto (if any), the information is provided on an AS-IS basis without any express or implied warranties or liabilities.  To the extent you are relying on this information, you are doing so at your own risk.   If you are not the intended recipient, please notify the sender immediately by replying to this message and destroy all copies of this message and any attachments. ASML is neither liable for the proper and complete transmission of the information contained in this communication, nor for any delay in its receipt. 


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=royale@xxxxxxxxxx