Home > Software engineering >  How can i get script for existing database?
How can i get script for existing database?

Time:05-03

My problem is that i need to provide script for creating my database to my teacher. I have created it but i didnt save anything. May i somehoves get a script for creating database and all tables which are in it, if i have this base on my sql server?

base

CodePudding user response:

It depends on your IDE and DB, but it's about the similar actions for all cases. For example:

  1. SSMS - Object Explorer -> Databases -> Tasks -> Generate Scripts -> Script all objects in the selected database -> Next
  2. DataGrip - right click on DB -> SQL scripts -> Generate DDL...

In any case, this can be done using any IDE, and you can select parameters in the settings (create only a structure or additionally add data from tables to the script, etc.)

CodePudding user response:

  • a1. Right-click on the Database you want to export
  • a2. Select "Tasks / Generate Scripts..."

This will open the "Generate and Publish Scripts" wizard.

On the "Choose Objects" tab:

  • b1. Pick all your database tables
  • b2. Select "Single File"
  • b3. Click Advanced Options and select "Table/View Options" / "Script Indexes"
  • Related