Help › Explore a database
Show an object's definition
Read the statement that creates a table, or the source of a view, function, procedure, trigger or sequence, and open it in the editor.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
Querlyn can show you the SQL behind an object in a tab of its own: the
CREATE TABLE of a table, or the source of a view, a function, a
procedure, a trigger and other objects. Showing it runs nothing and changes
nothing.
Show it
- Select the object in the sidebar.
- For a table, choose . For any other object, choose . The object's right-click menu has the one that applies.
A tab opens, titled with the object's name and DDL or Definition. The text is colored like SQL in the editor and has line numbers, but cannot be edited. Showing the same object again brings its tab forward.
Which kinds of object have a definition depends on the database; see Objects whose definition can be shown.
What the tab offers
| Button | Shortcut in the tab | What it does |
|---|---|---|
| Copy | ⌘C on macOS or Ctrl+C on Windows and Linux | Copies all of the text. |
| Open in Editor | ↩ on macOS or Enter on Windows and Linux | Opens a script for the object in a new query tab on the same connection, on the object's database. Nothing runs until you run it. |
| Reload | ⌘R on macOS or Ctrl+R on Windows and Linux | Reads the object from the database again. |
| Stop | ⌘. on macOS or Ctrl+. on Windows and Linux | Stops reading. Shown while the object is being read. |
The arrow keys, ⇞ on macOS or PageUp on Windows and Linux, ⇟ on macOS or PageDown on Windows and Linux, ↖ on macOS or Home on Windows and Linux and ↘ on macOS or End on Windows and Linux scroll. You cannot select part of the text or search in it; use Open in Editor for that.
What the text is
A table's DDL is written by Querlyn from the table's columns, defaults, keys and checks, followed by its indexes and comments. It is the same text the table designer would write, so tables read alike on every database. It does not include partitions, storage options, grants or the table's triggers (a trigger has its own Show Definition).
Any other object's definition is the database's own text, as the database keeps or prints it, ended so that it can run as a script. The object's comment follows it where there is one. Nothing is reformatted: if the database keeps a view's query on one long line, so does the tab. Open it in the editor and use to lay it out.
What Open in Editor writes
Open in Editor never opens a script that drops something.
- Where the database can replace an object in place, the script does that:
CREATE OR REPLACEon PostgreSQL, Redshift, Oracle, Snowflake and others,CREATE OR ALTERon SQL Server. - Where it cannot (a materialized view, a trigger on PostgreSQL or SQLite,
a routine on MySQL), the script is the plain
CREATE, under a comment that says the object cannot be replaced in place and shows theDROPstatement to run first, commented out. - A table or a sequence opens as its plain
CREATE.
When the definition cannot be shown
The reason takes the text's place, with Reload and Copy Diagnostics:
| Message | Meaning |
|---|---|
| "… was not found." | The object was dropped or renamed since the sidebar was read. Refresh the sidebar. |
| "The server does not show the definition of …" | It may be encrypted, or your login may not be allowed to read it. |
| "Reading the definition took too long and was stopped." | Reading is limited to 60 seconds. |
| "Reading the definition was stopped." | You chose Stop. |
A definition tab stays open when its connection closes. Reload connects again first.
What is not offered
- Definitions of indexes, users, roles and extensions.
- Several objects in one tab, or a script for a whole schema. To script a schema's differences from another, see Compare two schemas.
- Jumping from a name in the editor to its definition.
Help for Querlyn 0.1.0. All help topics