CoraDB WebSQL
A web client for CoraDB databases, relational and graph: define connections, browse the schema, write and run SQL, and work with the results.
Getting started
The window
- Header: the menus (Query builder, Decompile schema, Run batch SQL script..., Export/Import, View, Tools, Settings, Help) and the light/dark theme switch.
- Database tree on the left: your connections and everything in each database.
- Query tabs on the right: one SQL editor per tab, with its results below it.
- Status bar at the bottom: what the active tab is doing, and the connection's mode, engine version, auto-commit state and time.
The tree and the editor are separated by a splitter you can drag; so are the editor and its results. Sizes are remembered.
First steps
- Click Connections... above the tree and define a connection (see Defining a connection).
- Right-click the connection and choose Open connection, or simply expand it.
- Right-click the connection and choose Open a new SQL editor, type a statement and press Ctrl+Enter.
A DEV tag next to the version in the header means you are using a development copy of the app.
Connections
Defining a connection
Connections... opens the list of database connections. For each one you give:
| Field | Meaning |
|---|---|
| Name | What the tree shows. When empty, the tree shows database@host:port. |
| Host, Port | Where the CoraDB broker listens (port 33000 by default). |
| Database | The database to open. |
| User, Password | The database account. |
| Save password | On by default: the password is kept in this browser (an empty password too), encrypted with a key the browser keeps and does not let anyone read — so a copy of the browser's data does not give it away. Encryption needs the app opened over HTTPS or from localhost; otherwise the password is kept unencrypted, and the dialog says so. Off: it is asked for the first time the connection is opened in a browser session. Turning it off and clicking Update deletes a saved password. |
Use Test connection to try the details before saving them. Connections are stored only in the browser, so each browser (and each computer) has its own list.
Opening and closing
Right-click a connection in the tree. A closed connection offers Open connection, Open a new SQL editor and Run batch SQL script...; an open one also offers Close connection, Expand/Collapse all, the transaction isolation level, the session timezone, SHOW statements and Refresh schema.
An open connection is shared by every query tab that uses it: they share its transaction, its isolation level and its settings, the way any SQL client works.
The icon next to a connection shows its state: green for open, grey for closed.
Checking connections
The Check connections button in the tree's toolbar asks every connection's database whether it answers, all at once, and marks each one open or closed. A connection that does not save its password is never opened by a check.
When the app starts, it opens again the connections that were open when it was closed — but only those that save their password. A connection that does not save its password is never opened on your behalf: open it yourself and type the password.
Saving and loading connections
Right-click Connections...:
- Save connections... writes your connections to a
.jsonfile: name, host, port, database and user. Passwords are never written to the file. - Load connections... adds the connections of such a file. A connection whose name is already defined (in any letter case) is skipped, and the message after loading lists which. Loaded connections ask for their password the first time they are opened.
Use this to move your connections to another browser or computer, or to give a set to a colleague.
Publishing a connection to other users
Right-click a connection and choose Publish connection to other users to offer it to everyone who uses this WebSQL server. What is offered is the name, host, port, database and user — never the password.
The next time another user opens the app, they are asked: The following connections were made public by another user. Do you want to add them? Each connection has a checkbox; OK adds the ticked ones to their list, without a password. A connection whose name they already use is added with (1), (2)… after the name.
- Each user is asked about a published connection only once, whatever they answer.
- Publishing the same connection again offers it again, to everyone.
- An added connection is the user's own copy: they can change it or delete it at any time, and later changes to the published one do not reach it.
"A user" here is a browser: the same person on another browser or computer counts as another user.
Read-only mode, isolation level and timezone
- DB Mode in the status bar switches the active connection between Read/Write and Read-only. Read-only refuses statements that change data or schema, and the result grids stop offering to edit.
- Set transaction isolation level (right-click an open connection) lists the levels by name — for example Read committed or Serializable — with the one in force marked.
- Set timezone... sets the session timezone used for date and time values.
Database tree
Toolbar
| Button | What it does |
|---|---|
| Connections... | Define, edit and delete connections. Right-click it to save or load connections from a file. |
| Dashboard | An overview of the selected connection's database: versions, record counts and server activity. It can refresh itself automatically. |
| Check connections | See Checking connections. |
# Calculate records count | Counts the rows of every table, node and edge of every open connection and shows the count next to each. |
| Expand all / Collapse all | Opens or closes every level of the tree. |
| Refresh | Reads the schema of the open connections again. |
The Filter objects box below the toolbar keeps only the objects whose names contain what you type.
What the tree shows
Under each open connection: Tables, Views, Nodes and Edges (graph classes), with their columns, indexes and references; Stored procedures, Triggers, Serials, Collations, Charsets, the Users, and the Savepoints defined in the current session. System tables and views are kept in folders of their own.
Everything below a folder is read when you first open it, so even a large database opens quickly. A column that takes part in a foreign key is marked; its target table is one click away.
The tree refreshes itself after you run a CREATE, ALTER, DROP or RENAME statement.
Right-click on a table, view, node or edge
- SELECT — the first rows, in a new results tab.
- Generate SQL —
SELECT,INSERT,UPDATE,DELETEand DDL templates, pasted into the editor. - SHOW — the SHOW statements that apply to the object.
- Start query builder... — opens the Query builder with this object on it.
- Health check... — the schema health check for this object.
- Find duplicates... — rows that repeat over the columns you pick.
- Calculate... — a profile of every column: values, distinct values, NULLs, minimum, maximum, sum and average.
- Merge into... — builds a
MERGEstatement from this table into another. - Edit... — edit the definition: columns, keys, indexes and comments. The generated
ALTERstatements are shown before they run. - Comment..., Change owner..., Update statistics....
- Connect nodes... (edges) — adds edges between nodes picked by their values.
- DROP — the
DROPstatement is pasted into the editor, never run. You run it yourself.
Drag an object from the tree into the editor to paste its name, or onto the Query builder's canvas to add it there.
Other right-click menus
- Column: Calculate (count, distinct, minimum, maximum, average…), Comment.
- Index: its
CREATEorDROPstatement. The Indexes folder offers Create index.... - Tables / Views folder: Create table..., Create view..., Expand all, Collapse all.
- Stored procedure, trigger: View SQL... and DROP. Serial: its current value, Get NEXTVAL, Edit and DROP.
- User: Properties..., Edit..., Show GRANTS, Comment, DROP USER (DBA and PUBLIC cannot be dropped).
- Savepoint: Rollback to that savepoint.
SQL editor
Query tabs
Each tab is a separate SQL editor with its own connection (chosen in the Connection box at the top of the tab) and its own results. Tabs are named <database>-<user>-<n>. Double-click a tab's name to rename it: Enter keeps the new name, Esc cancels, and an empty name goes back to the automatic one. Two tabs cannot have the same name. A renamed tab keeps its name when you change its connection. The + button opens a new tab; Alt+N and Alt+W open and close tabs. The tabs, their SQL and their connections are kept when you reload the page.
Running SQL
| Button / key | What runs |
|---|---|
| Execute (Ctrl+Enter) | The selected text. With nothing selected, the statement at the caret or the line at the caret, as chosen in Single statement execute mode (Execute current SQL at cursor is the default). |
| Execute script (Ctrl+Shift+Enter) | Every statement in the editor, in order. |
| Stop | Stops the run: the statement in progress and the rest of the script. |
| Commit / Rollback | Shown only while auto-commit is off: end the open transaction. |
Statements are separated by ;. Each statement that returns rows gets its own results tab; statements that change data are sent in batches (the size is set in Options). Stop at the first failing statement in Options decides whether a script carries on after an error.
A statement that fails is shown in a results tab with the database's own message, and the editor marks where the error is.
Switches above the editor
| Switch | When on |
|---|---|
| Check syntax before run | Each statement is checked against CoraDB's grammar before it is sent. One with an error is not run, and the error is marked in the editor. Off by default. |
| Clean previous results | A run replaces the results on screen. Off: the results of each run are added next to the previous ones. |
| Show query plan | The execution plan of each query is shown with its results. |
| Do not execute query | With Show query plan: only the plan is read, nothing runs. |
| Show trace | The engine's trace of each statement is shown after it runs. |
Editing tools
- Undo / Redo (Ctrl+Z / Ctrl+Y).
- Pretty-format (Ctrl+Shift+F) lays the SQL out with consistent indentation and keyword case.
- Check syntax (F8) checks the selection, or the whole script, against the grammar and against the names in the open connection's schema. Problems are listed in a window and marked in the editor.
- Insert SQL hint adds an optimizer hint (an index to use, a join order…) to the selected
SELECT. - Load a script file / Save the script to a file, and Clear the editor.
- Autocomplete (Ctrl+Space) offers keywords, tables and, after
table.or an alias, columns. - Ctrl+F finds and replaces; Ctrl+Alt+G goes to a line; Ctrl+/ comments a line; Ctrl+mouse wheel changes the font size.
- Right-click in the editor for format, copy, cut, paste and font size.
Query history
View ▸ Query history... (Alt+H) lists the statements run from this browser, with their outcome, duration and connection. Search it, copy a statement, open it in a new tab, run it again, remove it, or save the runs shown to a CSV, Excel or text file.
Results
The results grid
Each statement that returns rows gets a results tab. In the grid:
- Click a column header to sort; drag a column divider to resize it, double-click it to fit the column to its content.
- Filter shows a filter box per column: rows containing that text are kept (any letter case); start with
=for an exact match. - Large results are read a page at a time; use the paging buttons, or sort/filter, which read every row first so they apply to all of them.
- Refresh reads the rows again; Copy copies the ticked rows (or the page) to the clipboard; Export saves the result to CSV, TSV, JSON, HTML, SQL, Markdown or Excel.
- Click a cell to see the total, average, minimum and maximum of its column below the grid. The value panel on the right shows the clicked cell's whole value and follows the cell you click.
- Chart draws the result as a chart; Graph draws a
MATCHresult as a graph of nodes and edges. - Times are shown in ms, s, min or h, whichever reads best.
Editing data in the grid
When a SELECT reads from a single table, node or edge whose primary key is among the columns, the grid is editable:
- Click a value to change it; Apply saves the changes with generated
UPDATEstatements. - Add row adds a row, Inline at the bottom of the grid or in a Window with one field per column.
- Tick rows and use Delete to remove them.
Turn on Show SQL on Save data grid edit in Options to see the generated SQL before it runs, and Confirm before deleting rows to be asked first.
SELECT left the key out, the grid does not edit — a WHERE built from other columns could change rows you did not see. Adding rows still works. The connection must also be in Read/Write mode.Generate Delete SQL... (right-click) gives you the DELETE statements for the picked rows to check and run yourself, when the grid will not delete. With the primary key in the result, each row is named by its key. Without one, each row is named by all of its values, which works only when the result holds every column of the table (SELECT *); such a DELETE removes every row with the same values.
Large object (BLOB, CLOB) values are read-only. An edge row is added with Add edge, which asks for the two nodes it joins.
Query builder
Query builder in the header builds a SELECT without typing it.
- Drag tables, views or nodes from the tree onto the canvas. Their foreign keys are drawn as lines and become joins. Edges between nodes become graph patterns.
- Tick the columns to show. In the grid below the canvas set, for each column, an alias, sorting, grouping, an aggregate and conditions (right-click a column for filtering conditions).
- Tables that are needed to connect two others (a table between them, such as orders between customer and product) are added to the query by themselves.
- The SQL is shown as you build; send it to the editor or run it from there.
- The design is kept per connection, in this browser: reopening the Query builder on the same connection shows the last design. Clear starts a new one.
- The window can be maximized; it then fills the area beside the tree, so you can keep dragging objects onto it.
Decompile schema (diagrams)
Decompile schema draws a connection's schema:
- Relational — an entity-relationship diagram of the tables and their foreign keys.
- Graph — the node classes and the edges that join them.
Boxes can be moved; Auto-arrange lays them out again. Save the diagram as PNG or SVG.
Batch SQL scripts
Run batch SQL script... runs a .sql file, or statements pasted into it, on a connection — meant for large files such as a database dump, which would be slow to load into an editor. The run is done by the server: you see its progress, can stop it, and get a list of the statements that failed.
Export and import
Export data...
Exports the rows of the tables you pick to CSV or Excel (XLS) files, one per table. It runs on the server; you can keep working while it does.
Export database as SQL...
Writes a whole database as a SQL script: the CREATE statements (tables in dependency order, then foreign keys, indexes and views) and the rows as INSERT statements. Options control DROP IF EXISTS statements, a separate DDL file, multi-row INSERT statements and a maximum file size (larger dumps are split into several files).
Edge rows are written as INSERT EDGE statements. Each end is named by the node's primary key, or a unique key on columns that cannot be NULL; a node class with neither is named by all of its columns, and the script warns about it. The direction of each edge is read both ways (-> and <-) between every pair of node classes, and the total is checked against the edge table's row count: if they do not agree, that edge table is not written rather than written wrong, and the script says so.
Import data...
Imports a CSV (or TSV/TXT) file or an Excel workbook into a table. You map each column of the file to a column of the table (or leave it out), and see the first rows before importing. For an edge, you also map the columns that find the two nodes each row joins. Rows that cannot be imported are listed with the reason.
View menu
- Query history... — see Query history.
- Database tree — show or hide the tree.
- Data page statistics — a panel under the tree with the data page reads and writes of the statements you run.
Tools
Schema health check...
Checks a schema against design rules: every table has a primary key, every foreign key is indexed, no table is cut off from the others, names follow the naming style you expect (set in Options) and are not SQL keywords, text columns have a sensible length, dates are stored as dates, money is not held as a float, and more. Each rule is listed with what breaks it, marked as an error, a warning or advice. The Graph schema health check does the same for nodes and edges.
Sessions and locks...
The database's open transactions and threads: who is connected, what each is running, and which locks are held or waited for. Pick transactions and use KILL QUERY to interrupt their statement, or kill the transaction. The connections of this app in this browser are marked.
Users and privileges...
Create and edit database users: password, comment, groups and members, and the privileges on each object (with or without WITH GRANT OPTION). Effective privileges shows what a user can do through its groups as well.
Server health...
The state of the database server: buffer pool, volumes and free space, active log, job queues and critical sections, with tiles that summarise each. It can refresh itself every few seconds.
Settings
Options...
| Tab | Settings |
|---|---|
| General | Editor and grid font size; auto-expand menus on mouse hover. |
| Query | Default batch size; stop at the first failing statement; rows per page; rows for the graph view; maximum rows to load; undo steps; show SQL on Save data grid edit; confirm before deleting rows; what SQL picked from the tree does. |
| Other | The naming style the schema health check expects, and the defaults for Export database as SQL: DROP IF EXISTS statements, a separate DDL script file, multi-values INSERT statements, maximum file size. |
Options are kept in this browser.
Session settings...
Settings of a connection's database session: how long to wait for a lock, refusing UPDATE/DELETE without WHERE, refusing DDL, strict GROUP BY, the recursive CTE limit and the time zone. Each can be left at the server's default. Settings you change are applied again whenever the connection reopens.
Light and dark
The sun/moon button at the right of the header switches between the light and dark themes.
Status bar
- Confirm dangerous SQLs — when on, a statement such as
DROP,TRUNCATE, orDELETE/UPDATEwithoutWHEREasks for confirmation before it runs. - The state of the active tab: Ready, Executing..., or the outcome of the last run (statements, rows, time).
- The engine version of the connected database, and a link to coradb.ai.
- DB Mode: Read/Write or Read-only (click to switch).
- Auto-commit: ON or OFF (click to switch). With it off, Commit and Rollback buttons appear next to it and in the editor's toolbar.
- The date and time.
Keyboard shortcuts
Also available in the app under Help ▸ Keyboard shortcuts... (Alt+K).
| Keys | Action |
|---|---|
| Ctrl+Enter | Execute the selection, or the line or statement at the caret |
| Ctrl+Shift+Enter | Execute the whole script |
| F8 | Check the syntax, and the names against the open connection's schema |
| Ctrl+Space | Complete a keyword, table or column |
| Ctrl+Shift+F | Pretty-format the SQL |
| Ctrl+/ | Comment or uncomment the line |
| Ctrl+F | Find and replace |
| Ctrl+Alt+G | Go to line (a number, +n / -n, 50%, or line:column) |
| Ctrl+Z / Ctrl+Y | Undo / redo |
| Tab / Shift+Tab | Indent / outdent |
| Ctrl+mouse wheel | Make the editor text bigger or smaller |
| Alt+N | New query tab |
| Alt+W | Close the query tab |
| Alt+PageDown / Alt+PageUp | Next / previous query tab |
| Alt+H | Query history |
| Alt+K | Keyboard shortcuts |
| ← / → | Previous / next row in the record view |
Troubleshooting
"Could not reach the WebSQL server"
The browser could not reach the WebSQL server (not the database). Check that it is still running: the console it was started from says why it stopped. Results that were waiting are marked as lost; run them again once the server is back.
"Password required"
The connection does not save its password — for example one loaded from a connections file or added from a published connection. Type it once; it is kept for the rest of the browser session. To keep it for good, turn Save password on in Connections... and click Update.
A statement or script runs too long
Press Stop in the editor's toolbar. The database is asked to drop the statement; if it cannot, the connection is closed and opened again, and a message tells you so (an open transaction is then lost). Another user's long statement can be stopped from Sessions and locks.
The grid does not let me edit or delete
See Editing data in the grid: the table needs a primary key, the SELECT must include it, and the connection must be in Read/Write mode.
A new table does not appear in the tree
The tree refreshes itself after DDL run from an editor. For changes made elsewhere (another tool, another user), use Refresh in the tree's toolbar or Refresh schema on the connection.
See also: the CoraDB manual and the CoraDB SQL manual.