3.4. Importing Database Schema via CSV

Importing your database schema can sometimes be a tedious process. Fortunately, the "Import via CSV" method simplifies this procedure by generating a SQL query that fetches the required table and column names automatically.

In this guide, you'll learn how to use this method to quickly fetch and import your database schema.

If you don't already have the database schema in CSV format, follow these steps:

  1. Execute the SQL Query: Run the following SQL query on your database. This query fetches the necessary table and column names:

    -- SQL SERVER
    SELECT
      TABLE_SCHEMA AS [Schema],
      TABLE_NAME AS [Table],
      COLUMN_NAME AS [Column],
      DATA_TYPE AS [Type]
    FROM
    INFORMATION_SCHEMA.COLUMNS
    WHERE
      TABLE_SCHEMA = 'dbo'
    
    -- MYSQL
    SELECT
      TABLE_SCHEMA AS 'Schema',
      TABLE_NAME AS 'Table',
      COLUMN_NAME AS 'Column',
      DATA_TYPE AS 'Type'
    FROM
      INFORMATION_SCHEMA.COLUMNS
    WHERE
      TABLE_SCHEMA = "YOUR_DATABASE_NAME"
  2. Export the Result: After executing the query, export the result in CSV format. Most database management tools have an option to do this.

  3. Copy the CSV Content: With the exported CSV in hand, copy its contents.

  4. Paste in the Import Screen: Return to the "Import via CSV" screen and paste the copied CSV content in the text area.

Last updated