Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script schema of the entire database with Datagrip

Tags:

datagrip

Is it possible to script schema of the entire database (SQL Server or Postgres) using datagrip?

I know I can get DDL for table and view and source for each stored procedure / function on it's own.

Can I get one script for all objects in database at once?

Alternatively, is there a way to search through code of all routines at once, say I need to find which ones are using #table temp table?

like image 215
vittore Avatar asked Jul 27 '16 12:07

vittore


People also ask

How do I find the database schema in DataGrip?

Show and hide schemas In the Database Explorer (View | Tool Windows | Database Explorer), right-click a data source and navigate to Database Tools | Manage Shown Schemas. Select or clear checkboxes of schemas that you want to enable or disable. Press Enter .

How do I get DDL from DataGrip?

DDL statement for any object To do this, press Ctrl+Alt+G or choose Context menu → SQL Scripts → SQL Generator… and get the generated DDL of any kind of object (table, schema, procedure, whatever).

How do I import a schema into DataGrip?

In the Database Explorer (View | Tool Windows | Database Explorer), right-click a schema or a table and select Import/Export | Import Data from File(s). Navigate to the files that contain delimiter-separated values, select them, and click Open.


3 Answers

For now only dumping tables works. In 2016.3 EAP which will be available in the end of August there will be an integration with mysqldump and pg_dump.

Check the screenshot

like image 151
moscas Avatar answered Sep 26 '22 02:09

moscas


I was looking for this today and just found it. If you right click the schema you want to copy and choose "Copy DDL" this will copy the create script to the clipboard.

like image 21
RobbZ Avatar answered Sep 24 '22 02:09

RobbZ


To answer your second part of the question: quick and easy way to search for #table in all of your procedures you can do the following query

SELECT *
FROM information_schema.routines
WHERE routine_definition LIKE '%#table%'
like image 31
Arno Venter Avatar answered Sep 23 '22 02:09

Arno Venter