GoLand 2024.1 Help

Tables

A database table is a structure that organizes data into rows and columns. Data in a table is stored in a cell that is an intersection of a vertical column and horizontal row. The table has a specified number of columns, but can have any number of rows. With GoLand, you can perform data manipulation and data definition operations with tables.

In GoLand, you can work with a table in data editor. When you double-click a table in the Database tool window ( View | Tool Windows | Database) , the table is opened in the Table viewing mode of data editor.

Tables ( Table) can be found in the Database tool window. For the reference on other node and object icons, refer to the Data sources and their elements chapter of Database tool window topic. For the table column icons, refer to the Possible icon combinations for columns chapter.

Tables in Database

In GoLand, each table opens in a separate tab. The following rules are applied to long tab titles:

  • The Always show qualified names for database objects option is now turned off by default. Tab names for objects are qualified if you open two tabs of objects with the same name. For example, if you open two actor tables from different schemas, the schema name is added in the tab name.

  • If the data source has a name that is longer than 20 symbols, the name is truncated.

  • If you have only one data source, GoLand does not display the data source name in the tab name.

  • If a qualified object name has more than 36 symbols, it is truncated.

Working with tables

Create

  1. In the Database tool window ( View | Tool Windows | Database) , expand the data source tree until the nodes of databases or schemas.

  2. Right-click the database or schema node and select New | Table.

  3. In the Create dialog that opens, enter the name of your table in the Name field.

  4. Specify table settings (columns, keys, indexes, foreign keys, grants).

  5. In the Preview pane, you can view and change the generated SQL code.

  6. Click OK to add your table.

Create a new table

Delete

  1. Right-click a table and select Drop. Alternatively, press Delete.

  2. Click OK.

For more information about the dialog options, refer to Confirm Drop dialog.

Drop a table

Modify

Modify a table

Starting with GoLand 2022.1, you can change database-specific parameters of a table. The IDE generates fields for the Modify dialog automatically according to the properties received during the introspection. For example, by using this dialog in PostgreSQL, you can add and edit column check constraints.

  1. In the Database tool window ( View | Tool Windows | Database) , right-click a table and select Modify Table.

  2. In the Modify dialog, specify object settings that you need.

  3. Click OK save your changes.

Modify a table

Inspect same family objects in a table

  1. In the Database tool window ( View | Tool Windows | Database) , right-click a table and select Modify Table.

  2. In the Modify dialog, double-click the family node.

    Table with similar database objects in a family node of a Modify dialog

Enable read-only mode for a table

To protect a table from accidental modifications in the data editor, you can make the table read-only.

  • To enable read-only mode, click the Click to toggle the read-only attribute icon (The Click to toggle the read-only attribute icon) in the lower-right corner of the editor.

To turn off read-only mode, click the Click to toggle the read-only attribute icon again.

Enable the read-only mode for a table

Productivity tips

Modify a table from the data editor

You can modify a table while you edit table data.

  1. Double-click a table to open it in the data editor.

  2. Press Ctrl+F6.

  3. Modify data and click OK.

  4. Press Ctrl+F5 to reload the page.

Copy

You can duplicate the table data in the current schema or copy it to another schema or data source.

Copy table data

  • Drag a table to the node in which you want to create a copy. In the Import <table_name> Table dialog, ensure that mappings are correct and click Import.

  • Right-click a table and select Import/Export | Copy Table to (F5). In the Import <table_name> Table dialog, select the schema in which you want to create a copy, ensure that mappings are correct, and click Import.

    Create a table copy using context menu
  • In the data editor, click the Copy to Database icon (Copy to Database) and select a schema to which you want to copy the table.

    Check the video at youtube.com to see the live example.

    Create a table copy using data editor toolbar

Copy table structure

  • You can copy the table structure using SQL Generator. To do that, in the Database tool window ( View | Tool Windows | Database), right-click the table and select SQL Scripts | SQL Generator. Alternatively, press .

    For more information about the SQL Generator controls, refer to Generate DDL definitions for database objects.

    Copy table structure

Quick documentation

The quick documentation (Ctrl+Q) displays the information about table: data source, database, schema, name, auto-generated definition, and table preview. To see the table preview, click Show table preview.

PostgreSQL and MySQL table size in Quick Documentation popup

For PostgreSQL and MySQL databases, table preview also contains information about the table size.

Last modified: 17 June 2024