Columns
A column is a piece of data that is stored by a table. This data belongs to a particular type. A column may include text, numbers, or pointers to files in the operating system. Some relational database systems allow columns to include more complex data types like whole documents, images, or video clips.
Columns ( ) 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.
Hide, sort, filter, and group tree objects using the tree objects view options in the View Options menu.
In the Database tool window (View | Tool Windows | Database) , expand the data source tree until the nodes of tables.
Right-click the table node and select New | Column.
In the Modify dialog that opens, enter the name of your column in the Name field.
In the Preview pane, you can view and change the generated SQL code.
Click OK to add your column.
Right-click a column and select Drop. Alternatively, press Delete.
Click OK.
For more information about the dialog options, refer to Confirm Drop Dialog.
note
SQLite supports a limited subset of
ALTER TABLE
commands. In SQLite, you can rename a table, rename a column within a table, and add a new column to an existing table. For more information about the command in SQLite, refer to the official SQLite documentation.To delete a column in SQLite, right-click a table and select Modify Table. In the Modify dialog, select the column that you want to delete and click the Remove button (). The Modify action recreates a table without the deleted column.
Starting with PyCharm 2022.1, you can change database-specific parameters of a column. 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.
In the Database tool window (View | Tool Windows | Database) , right-click a column and select Modify Column.
In the Modify dialog, specify object settings that you need.
note
Column settings depend on the database vendor. For example, the Auto Increment checkbox is only available for SQLite, MySQL, and other vendors that allow it for a primary key column of an integer data type.
Click OK save your changes.
To reorder columns, drag the corresponding cells in the header row.
To hide a column, right-click the corresponding header cell and select Hide column.
Alternatively, you can right-click any of the cells in the header row and select Columns List CtrlF12. In the Columns List window, select a column name and press Space. You can hide all columns. To search through the column list, start typing a column name in the Columns List window.
Right-click any of the cells in the header row and select Columns List. Alternatively, press CtrlF12.
Select the hidden column (a strikethrough column name) and press Space.
tip
You can review the whole table structure in the Structure tool window (View | Tool Windows | Structure). The Structure tool window displays all columns.
Click the settings icon () and select Reset View. As a result, the data becomes unsorted, the columns appear in the order they were defined initially, and all the columns are shown.
You can assign HTML, CSS, XML, RegExp, or any other formal language for the whole column. So, when you have a piece of code inside the cell that belongs to the column, you can use code generation, code completion, and other IDE features.
To inject a language for the whole column, right-click the corresponding header cell, and select Set Highlighting Language. In the list of supported languages, select the language that you want to inject.
Place the caret between two columns, so it changes to the resize mode. Drag it to the preferred position.
To learn how to work with column data, refer to the topics of Data editor and viewer section:
You can sort data by clicking a column's header, or by entering a sorting query into the corresponding field. By default, each time you sort data, PyCharm sends a new
ORDER BY
query to the database. You can also change the setting and sort data on the client side.Use one of the following ways to filter data:
Specify filtering conditions.
Run a search on the table.
Enter a filtering query into the corresponding field.
In the Database tool window (View | Tool Windows | Database) , select any database objects and drag them to your code.
Thanks for your feedback!