0

I want to import my SQL database with below two conditions

  1. Import data and structure for some static tables.
  2. Import structure only for all the tables which are not static means tables values are get updated after moving an application from one server to another server.

Can any one know the SQL command to dump the database with above-matching conditions?

2 Answers 2

4

there is a no data parameter for this:

mysqldump -uroot -p --no-data dbname > db.sql

this will export your database with no data to a file called db.sql

you can go onto specify tables after dbname

mysqldump -uroot -p --no-data dbname tbl1 tbl2 > db.sql

To import the files you do:

mysqldump -uroot -p dbname < db.sql

or you can use:

mysql -uroot -p dbname and then after logging in: source /path/to/db.sql

you don't need to specify tables because it's all inside the .sql file

Sign up to request clarification or add additional context in comments.

2 Comments

The above command will import structure but, while performing import operation I want to import both data and structure to my static table named country.
if your table country is in the sql dump then it will be imported? Or you can use the second command to get country as an individual .sql file and source it in mysql command line (will update answer on how-to)
-2

(1)

Open Sql Server Managment studio
Right click database → Tasks → Generate Scripts → Choose DB → Change “Script Data” option to true → …
Right click database → Tasks → Backup → ...

(2)

select *
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME='tableName'

5 Comments

your second option won't export it - just show it - also not everyone uses SQL Server Management Studio - in fact I didn't even know it existed.. but to be fairs I'm an anti-ui guy :p
i suggest you to don't downvote any answer. As this will discourage a person to answer.
we downvote when the answer is bad, I mean no offense honestly but to keep SO clean and what not we need to downvote bad answers. This is a benefit though as it allows you to learn from it :)
@ThisGuyHasTwoThumbs It not necessary. You can upvote if the answer works for you. otherwise leave it. By the way this answer is not completely bad as it not answering totally out of context.
it is - that's why the functionality is there, don't take it to heart man :) and it kind of is, your solution is for one application and your second solution selects data, it doesn't export it. This means this isn't an answer at all, if you get my meaning? It's out of context because it it doesn't answer the OP's question

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.