--- title: Get started with TotalSQL project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/getting-started/ updated: 2026-12-02T15:40:26.075Z --- # Get started with TotalSQL > TotalSQL opens your SQL databases in one window: PostgreSQL, MySQL, MariaDB, SQL Server and SQLite. You read and change their rows, change their structure, write queries and make copies. ![The rows of a table of PostgreSQL in TotalSQL, with the tables and the rest of the database at the side](https://totaljs.es/_totaldesktop/shots/totalsql-1.webp) ## Install it Download TotalSQL for macOS, Windows or Linux from [its page](https://totaljs.es/en/totaldesktop/totalsql/#download). [Install the apps](/totaldesktop/latest/guides/install/) explains each system step by step. There is nothing else to install to work with the five kinds of database. ## Open your first database 1. Press **New connection**. 2. Write a name, and choose the kind of database in **Kind**. 3. For a server, write its address, the user, the password and the database. For SQLite, choose the file with **Browse…** 4. Press **Try it**. When it can connect, it says **It works** and the version of the server. 5. Press **Save and open**. The tables of the database show at the side. 6. Press a table to see its rows. A new connection asks before any change, so you can look around without fear. [Choose how careful it is](/totalsql/latest/guides/care/) explains it. ## The parts of the window | Part | What it is for | | --- | --- | | The strip above the list | Your [open connections](/totalsql/latest/guides/connections/#work-with-several-at-once), to go from one to another | | The list at the side | The [connections](/totalsql/latest/guides/connections/) that you have saved or, in an open one, its [tables](/totalsql/latest/guides/tables/) and views, and [the rest of what it has](/totalsql/latest/guides/functions-and-more/) | | The tabs | The tables and the queries that are open | | **Data** | The [rows](/totalsql/latest/guides/rows/) of a table, and [their changes](/totalsql/latest/guides/edit-rows/) | | **Structure** | The [columns, indexes, relations and rules](/totalsql/latest/guides/structure/) of a table | | **Query** | A new tab to [write SQL](/totalsql/latest/guides/queries/) | | **AI** | [Connect an AI](/totalsql/latest/guides/connect-an-ai/) to the database in view | | The line at the bottom | Where you are connected, and how careful the connection is | Press the right button on a connection, a table, a column or a value to see what you can do with it. In a narrow window, the list is behind the button **Show the sidebar**. --- title: Save and open connections project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/connections/ updated: 2026-12-02T15:40:26.075Z --- # Save and open connections > Save each database once, with its password, and open it with a click. Several can be open at the same time. ![The list of saved connections, with the mark of each kind of database and its environment](https://totaljs.es/_totaldesktop/shots/totalsql-2.webp) ## The fields | Field | What to write | | --- | --- | | **Name** | What you call it | | **Kind** | PostgreSQL, MySQL or MariaDB, SQL Server or SQLite | | **Server** and **Port** | The address. Without a port, the usual one of its kind: 5432, 3306 or 1433 | | **User** and **Password** | Those of the database. In SQL Server, a login of SQL Server, not one of Windows | | **Database** | Empty opens the default one of the user | | **Database file** | Only for SQLite | | **Encryption** and SSH | [Protect a connection](/totalsql/latest/guides/secure-connections/) | | **Changes** and **Environment** | [Choose how careful it is](/totalsql/latest/guides/care/) | | **Group** | Connections with the same group show together | **Try it** connects without saving. **Save** keeps the connection, and **Save and open** also opens it. In SQLite, if there is no file at that path, TotalSQL says **There is no file there** when you open the connection. Press **Make a new database** to have an empty one, or correct the path. ## The passwords They are kept in the secure store of your system, called the keychain in the app. When you edit a connection, an empty **Password** keeps the one that is there. Without the mark in **Keep the passwords in the keychain of the system, so it does not ask again**, nothing is kept and TotalSQL asks each time. ## Find them With five connections or more, the list has the field **Find a connection**. It looks in the name, the server, the database, the file, the group and the kind. Press the name of a group to fold it. With the right button, a connection has **Open**, **Edit…**, **Copy the address** and **Delete…** > Deleting a connection also deletes its history and its passwords. Its saved queries stay for every connection, unless you turn off **Keep its saved queries, for every connection**. The database is not touched. ## Work with several at once Each open connection has its place in the strip above the list, with its own tabs, results and changes. Press one to go to it. The first button of the strip goes back to the list, to open another. To close one, press the cross next to the name of the database. After you edit a connection that is open, close it and open it again. ## Change of database When the server has several databases, choose another in the list above the tables. Choosing another database closes the tabs of the one that you leave. If something in them is not saved, TotalSQL says what it is and asks first. ## When the connection is lost TotalSQL does not connect again by itself. If it says **The connection to the server was lost**, close the connection and open it again. Copy first the text of your queries. --- title: Protect a connection project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/secure-connections/ updated: 2026-12-02T15:40:26.075Z --- # Protect a connection > Encrypt the connection to a server, or go through an SSH server, so nobody reads your password and your data on the way. ## Which one to choose | The database is | Choose | | --- | --- | | On this computer | **Not encrypted**, which is what a new connection has | | On a server that you reach by SSH | **Connect through an SSH server** | | On another computer, reached directly | **Encrypted, certificate checked** | TotalSQL warns you when a connection goes to another computer without encryption and without SSH. ## Encryption - **Encrypted, certificate checked**: the server must have a certificate valid for its name. Public authorities are accepted. If your server has its own authority, choose its file (PEM) in **Certificate authority file**. - **Encrypted, certificate not checked**: the connection is private, but the server does not prove who it is. It is for servers with a certificate that they made themselves. ## Connect through an SSH server 1. Turn on **Connect through an SSH server**. 2. Write the SSH server, its port and its user. 3. In **Sign in with**, choose **Private key**, **SSH agent** or **Password**. On Windows, the agent is the one of OpenSSH, and its service must be running. 4. In **Server** and **Port**, above, write where the database is *as seen from the SSH server*. It is often `localhost`. If the SSH server cannot reach the database, TotalSQL says so before it tries to sign in. ## A database in a Docker container Write the name of the container in **Server**, and the port that the database has inside the container. You do not have to publish that port. TotalSQL asks Docker on the SSH server for the address of the container each time, because it changes. The SSH user must be allowed to run `docker`, or to run it with `sudo` without a password. ## Trust the SSH server The first time, TotalSQL shows the key of the server in **Trust this SSH server?** Check it with whoever runs the server, and press **Trust and open**. It is not asked again. > If it says **The key of the SSH server changed**, stop. The server may have been installed again, or someone may be in the middle. Press **Replace the trusted key** only when you know the new key is right. ## What is kept The password of the database, and the SSH password or the passphrase of your key, go to the secure store of your system. Your private key stays in its file: TotalSQL keeps only the path. --- title: Choose how careful a connection is project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/care/ updated: 2026-12-02T15:40:26.075Z --- # Choose how careful a connection is > Each connection has a care level, which says what may run on it, and an environment, which tells production from a copy at a glance. Both are in **Care**, when you edit the connection. ## The care level Choose it in **Changes**: | Level | Statements that change data | Statements that destroy data | | --- | --- | --- | | **Run as written (destroying asks)** | Run | Ask | | **Ask before any change** | Ask | Ask | | **Read-only** | Refused | Refused | A new connection has **Ask before any change**. The line at the bottom of the window says **Asks before changes** or **Read-only**. When a statement asks, you see it whole, with **Changes data** or **Destroys data**, and nothing runs until you press **Run**. ## What destroys data - `DROP` and `TRUNCATE` - `ALTER` when it drops something - `UPDATE` and `DELETE` without `WHERE` ## How a statement is judged TotalSQL reads the words of the statement. What it does not know counts as a change, so it may ask for a statement that changes nothing, such as `SET`. `EXPLAIN ANALYZE` counts as the statement that it explains, because it runs it. The words do not say what a function does. So, with **Ask before any change** and **Read-only**, a statement that reads runs in PostgreSQL, MySQL, MariaDB and SQLite in a way that lets nothing be changed. If a function that it calls changes data, the database refuses it, and TotalSQL asks or refuses as with any other change. In SQL Server, functions cannot change data. > In MySQL and MariaDB, this does not work inside a transaction that you have open, nor while you hold tables with `LOCK TABLES`: there, a `SELECT` runs as it is. ## Read-only Besides refusing statements, TotalSQL opens the database itself as read-only in PostgreSQL, MySQL, MariaDB and SQLite. SQL Server has no such thing for a connection, so there the only guard is TotalSQL. For real safety, use a database user that can only read. On a read-only connection, the buttons that change rows and tables are not there. ## The other changes always show their SQL Saving [rows](/totalsql/latest/guides/edit-rows/) and changing [a table](/totalsql/latest/guides/structure/) show you their statements before they run, with any level but read-only. The changes proposed by [an AI](/totalsql/latest/guides/connect-an-ai/) always ask. ## The environment Choose it in **Environment**. It is a mark next to the database, and it changes nothing in what may run: | Environment | Mark | | --- | --- | | **Local**, **Development**, **Testing** | A green circle | | **Staging** | An amber triangle | | **Production** | A red square | | **None** | No mark | --- title: Look at the rows of a table project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/rows/ updated: 2026-12-02T15:40:26.075Z --- # Look at the rows of a table > Open a table to see its rows 500 at a time, filter and sort them, and arrange the columns to your taste. ## Open a table Press it in the list. **Find a table** filters the list by name. The number at the end is an estimate of its rows, when the database gives one. The exact count shows below the rows, with the pages. The arrows at the bottom right go to the next page and to the previous one. ## Filter 1. Press **Filter**. 2. Choose the column and the condition, and write the value. 3. Press **Add**. Add as many filters as you need: a row must pass them all. The cross of a filter removes it. With **is one of (a, b, c)**, write the values separated by commas. The conditions about text, such as **contains**, also look inside numbers and dates. The short way is the right button on a value: **Only rows with this value**. ## Sort Press the name of a column. Press it again for the opposite order, and once more for none. The order is of the whole table, not only of this page. ## Arrange the columns - Drag the name of a column to move it. - Drag the right edge of its name to change its width. A double click on the edge gives back its own width. - **Columns as they come**, with the right button, undoes both. Each table remembers its columns on this computer. ## See a whole row Press **Show the row on the side**. Each value of the selected row shows whole, with JSON laid out, however long it is. The tables and the queries that you open next show it too. In the grid, a value of more than 300 characters is cut. ## Copy With the right button on a value: - **Copy the value**, or ⌘C on the Mac and Ctrl+C on Windows and Linux. - **Copy the row**, to paste it in a spreadsheet. **Copy the SQL of this page**, at the bottom, copies the statement with your filters and your order, to go on from it in [a query](/totalsql/latest/guides/queries/). To take all the rows, [export the table](/totalsql/latest/guides/export/). ## Views A view opens as a table does, only to read. --- title: Change, add and delete rows project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/edit-rows/ updated: 2026-12-02T15:40:26.075Z --- # Change, add and delete rows > Your changes wait in the grid until you read their SQL and save them together. Nothing reaches the database before that. ## Change a value 1. Double-click it, or go to it and press Enter or F2. 2. Write the new value, and press **Change**. The cell is marked. You can also change the values of the selected row in [the row on the side](/totalsql/latest/guides/rows/#see-a-whole-row). Each type has its own field: | Type | How it is changed | | --- | --- | | Yes or no | **True**, **False** or **NULL** | | Dates and times | A calendar and a clock, and **Now**. The time zone of the value stays | | JSON | A text that is checked as you write, and **Lay out** to arrange it | | UUID | A text, and **New** to make one | | Binary | Hexadecimal, as `0x0a1b` | | Lists of PostgreSQL | As the database writes them: `{a,b,c}` | **Set NULL** takes the value away, where the column allows it. An empty text is not the same as NULL. ## Add a row Press **Row**, fill in the fields and press **Add**. An empty field takes the default of its column, and **needed** marks those that have none. The new row does not show in the grid until you save: the line at the bottom counts it. ## Delete a row Select the row and press the bin, or choose **Delete this row** with the right button. The row is crossed out. **Keep this row** takes it back. ## Save 1. Press **Save**, which says how many changes wait. 2. Read the statements. 3. Press **Save**. They run together: if one fails, none is kept. Each change must touch exactly one row. If someone deleted the row or changed its key in the meantime, nothing is saved, and TotalSQL shows the statement. If someone changed another value of the row, yours takes its place. **Discard** forgets all the changes that wait. Sorting, filtering, changing the page and reloading read the rows again, so TotalSQL asks before it loses the changes that wait. It also asks when you close the tab, the connection or the window, and when you quit from the menu. ## When rows cannot be changed The line at the bottom says why: - **Rows have no primary key, so they are not edited here**: TotalSQL needs a primary key, or a unique index on columns that are never NULL, to know which row to change. Use [a query](/totalsql/latest/guides/queries/). - **This connection is read-only**: change its [care level](/totalsql/latest/guides/care/). - **A view is read, not edited, here**. Columns filled by the database, such as a counter or a computed value, cannot be changed. --- title: Make, empty and drop tables project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/tables/ updated: 2026-12-02T15:40:26.075Z --- # Make, empty and drop tables > Make a table by filling in its columns, or take one away. In both cases you read the SQL before it runs. ## Make a table 1. Press **New table…**, the plus next to **Find a table**. 2. Write its name. If the database has several schemas, choose one. 3. Fill in the columns. There are two to begin with: a key called `id`, which the database numbers, and an empty one for text. 4. Press **Column** for each one more. Those without a name are left out. 5. Press **Review**, read the statement, and press **Make the table**. **Back** returns to the columns. | Column of the form | What it means | | --- | --- | | **Type** | Choose one of the common types, or write any that your database has | | **Default** | An expression: `0`, `'new'`, `now()` | | **NULL** | It may have no value | | **Key** | Part of the primary key. Mark several for a key of several columns | | **Numbered** | The database gives the numbers: 1, 2, 3… Only for a key | Then add its [indexes, relations and rules](/totalsql/latest/guides/structure/). In SQLite, relations and rules are set when the table is made, so write its `CREATE TABLE` in [a query](/totalsql/latest/guides/queries/) if you need them. ## Rename a table In **Structure**, press **Rename the table…** Views, functions and programs that name the table are not changed with it. ## Start a query on a table With the right button, **New query on it** opens a query that takes the first 100 rows of the table, in the words of your database and with the name between its quotes. **Copy the name** copies the name of the table, with its schema. ## Empty a table Choose **Empty…** with the right button. Every row goes and the table stays. If other tables point to this one, the database may refuse. ## Drop a table or a view Choose **Drop…** with the right button. A table goes with every row that it has. > Emptying and dropping cannot be undone. [Export the table](/totalsql/latest/guides/export/) first if you may need it. On a read-only connection you cannot make, rename, empty or drop anything here. ## After a change made elsewhere If another program made or dropped a table, press **Reload the tables**. --- title: Change the structure of a table project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/structure/ updated: 2026-12-02T15:40:26.075Z --- # Change the structure of a table > See what a table is made of, and change its columns, indexes, relations and rules. Each change waits until you read its SQL and run it. ## Read the structure Open a table and press **Structure**. It begins with the table in words: what names each row, which tables it points to, what a new row has to bring. Then come its columns, indexes, relations and rules, and the SQL that makes it. Press the name of another table in **Relations** to open it. ## Prepare your changes | To | Press | | --- | --- | | Add a column | **Column** | | Change the name, the type, the default or the NULL of a column | The pencil of its row | | Add an index | **Index**. Its columns go in the order in which you mark them | | Point to another table | **Relation**. Choose the columns, the other table, and what happens when the row pointed to goes away | | Add a condition that every row must pass | **Rule**. Write it as SQL: `price >= 0` | | Drop any of them | The bin of its row | Each change goes to a list above the columns. The cross of a change takes it out. ## Save them 1. Press **Review and save**. 2. Read the statements. They run in that order. 3. Press **Run**. In PostgreSQL, SQL Server and SQLite, if one fails, none is kept. MySQL and MariaDB keep each change of structure as soon as it runs, so those before the one that fails stay. The list stays when you go to **Data** and back. If you close the tab before you run it, TotalSQL asks. When changes of rows wait too, it asks before you change the structure, because the rows are read again after it: save them first. > Dropping a column loses its values for good. ## What happens when the row goes away | Choice | What the database does | | --- | --- | | **Refuse to drop it (the usual)** | The row cannot be dropped while others point to it | | **Drop these rows with it** | Drops the rows that point to it | | **Empty the column here** | Puts NULL in the rows that point to it | | **Refuse, at once** | Refuses without waiting for the end of the transaction, in the databases that tell them apart | | **Put the default here** | Puts the default of the column | ## What needs a query - The key of the table, and its columns, cannot be dropped here. - The type of a column that the database fills. - The comments of columns, which are only shown. - The definition of a view. - In SQLite, the type, the default and the NULL of a column, and the relations and the rules. SQLite needs the table to be made again for that. A new column that cannot be NULL needs a default. --- title: Write and run queries project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/queries/ updated: 2026-12-02T15:40:26.075Z --- # Write and run queries > Write SQL in the dialect of your database, run all of it or a part, and keep what you want to use again. ## Run it 1. Press **Query**, or ⌘T on the Mac and Ctrl+T on Windows and Linux. A connection opens with a query ready. 2. Write one or more statements. The editor offers the words of SQL and the names of your tables. 3. Press **Run**, or ⌘↵ on the Mac and Ctrl+Enter on Windows and Linux. If you have selected text, only that runs. If not, everything does. Statements that change data may ask first: it depends on the [care level](/totalsql/latest/guides/care/). A `SELECT` may ask too, when a function that it calls changes data: the statements after it wait for your answer. Scripts with `GO` (SQL Server) and `DELIMITER` (MySQL and MariaDB) are understood. In SQL Server, a function, a procedure or a trigger goes on until the next `GO`. ## Read the results Each statement has its result, with its rows or how many it changed, and its time. With several statements, there is a tab for each. If one fails, those after it do not run, and those before it stay done. To undo them together, write your own transaction. A result keeps 200 000 rows at most, and says when **more were left out**. Its columns move as [those of a table](/totalsql/latest/guides/rows/#arrange-the-columns). You can see [the row on the side](/totalsql/latest/guides/rows/#see-a-whole-row), only to read. **Copy the result, to paste in a spreadsheet** copies all of it with the names of the columns. **Export…** [saves it to a file](/totalsql/latest/guides/export/). ## Stop it Press **Stop** while it runs. A connection runs one statement at a time, so its tables wait until a long query ends. In SQL Server, stopping connects again: temporary tables and open transactions are lost. ## Open a SQL file **Open a SQL file…** adds the text of a `.sql` or `.txt` file, in UTF-8 and of 8 MB at most, to the query. Nothing runs until you press **Run**. ## Find an earlier one **History** has the statements run on this connection, with their time and whether they failed. Write in **Search** to find one, and press it to add it to your query. The last 2000 are kept, and the dialog shows the 200 newest that match. > The history keeps statements as you wrote them, also a password inside one. **Clear history** deletes it all. ## Keep a query Press **Save this query…** and write a name. **Saved queries** has those of this connection: press one to add it to the query. A saved query is not changed in place. Save the new text, and delete the old one. The text of a query goes away with its tab. If it is nowhere else (it is not saved, and not all of it has run and is in the history), TotalSQL asks before you close the tab, the connection or the window, and when you quit from the menu. --- title: See functions, triggers and more project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/functions-and-more/ updated: 2026-12-02T15:40:26.075Z --- # See functions, triggers and more > Below the tables, the list has the rest of what your database holds, each with the SQL that makes it: to read it, to copy it or to change it. ## What each database has | Section | PostgreSQL | MySQL and MariaDB | SQL Server | SQLite | | --- | --- | --- | --- | --- | | **Functions** | Yes | Yes | Yes | No | | **Procedures** | Yes | Yes | Yes | No | | **Sequences** | Yes | No | Yes | No | | **Types** | Yes | No | Yes | No | | **Triggers** | Yes | Yes | Yes | Yes | | **Events** | No | Yes | No | No | | **Extensions** | Yes | No | No | No | | **Extensions to add** | Yes | No | No | No | | **Roles and users** | Yes | Yes | Yes | No | Press a section to unfold it. **Find a table** also looks in the names of these things. If your user may not read a section, the end of the list says so: **Not readable with this user**. ## See how something is made Press it. A tab opens with its SQL. **Copy** copies it, and **Reload** reads it again. For a user of MySQL or MariaDB, the SQL has its permissions. Passwords are never shown. The range types of PostgreSQL and the table types of SQL Server have only a note, without their SQL. ## Change it 1. Press **Change it in a query**. The SQL goes to a new query. 2. Change it there, and press **Run**. The functions and procedures of PostgreSQL come as `CREATE OR REPLACE`, which takes the place of the old one. In the other cases the SQL is a `CREATE`, and the database refuses it while the old one exists. Write a `DROP` before it, or change `CREATE` to `ALTER` in the functions, procedures and triggers of SQL Server. > A `DROP` that runs before a `CREATE` with an error leaves you without the thing. Copy its SQL before you begin. ## Make a new one Press the plus of the section. A query opens with a first draft in the words of your database, for example **New function…** Change the names and the body, and run it. Extensions and roles have no draft. ## Add an extension of PostgreSQL **Extensions to add** has those that the server offers and the database does not have yet. Press one, then **Change it in a query**, and **Run**. Your user needs permission for it. --- title: Export a table or a result project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/export/ updated: 2026-12-02T15:40:26.075Z --- # Export a table or a result > Save the rows of a table, or the result of a query, to a file for a spreadsheet, for a program or for another database. ## Export a table 1. Open the table, and filter or sort it if you want. 2. Press **Export the table…**, the arrow at the bottom. 3. Choose the **Format**, and press **Choose where…** Every row that passes your filters is written, not only this page, in the order that you chose. Changes not saved do not go into the file. Views are exported in the same way. While a large table is written, the rest of that connection waits. ## Export a result In a query, press **Export…** above the result. If the query returned more rows than the result keeps, only those kept are written, and the dialog says so. To have them all, export the table or a view. To paste a result in a spreadsheet without a file, press **Copy the result, to paste in a spreadsheet**. ## The formats | Format | What it is | From | | --- | --- | --- | | **CSV** | Commas, in UTF-8, with the names of the columns in the first line | Tables and results | | **CSV for Excel** | The same, with the mark that Excel needs to read accents | Tables and results | | **JSON** | A list with an object for each row | Tables and results | | **SQL (INSERT statements)** | An `INSERT` for each row, in the dialect of the database | Tables | ## How values are written - In CSV, NULL is an empty field, and an empty text is `""`, so you can tell them apart. - In JSON, numbers keep all their digits, yes and no are `true` and `false`, and the JSON of a column goes in as JSON. - Binary values are written in hexadecimal. - In `INSERT` statements, the columns that the database computes are left out. The separator of both CSV formats is the comma. If your spreadsheet expects another one, import the file and choose the comma there. ## If it fails The file takes its place only when it is complete. If an export fails, there is no half file, and one with the same name stays as it was. ## A whole database To take all the tables with their structure, [make a copy of the database](/totalsql/latest/guides/copy-a-database/). --- title: Make a copy of a database project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/copy-a-database/ updated: 2026-12-02T15:40:26.075Z --- # Make a copy of a database > TotalSQL writes a whole database to a SQL file that makes it again, for the five kinds of database and with nothing else to install. ## Make the copy 1. Open the connection, and press **Export the database…**, the arrow next to its name. 2. Leave **With the rows of every table** on, or turn it off to have only the structure. 3. In **Besides the tables and the views**, choose what else goes in. All of it is marked at first. 4. Press **Choose where…** A large database takes a while. When it ends, the line at the bottom says how many tables, views and rows were saved. In PostgreSQL, you can also [make the copy with pg_dump](/totalsql/latest/guides/pg-dump/), which has more in it. ## What is in the file The tables with their rows and their counters, their relations, and the views. And what you chose of the extensions, types, sequences, functions, procedures, triggers and events of your database. The relations, the triggers and the events are made after the rows. So tables can point to each other, and restoring does not set anything off. ## What is not - Roles and permissions, which belong to the server. - In PostgreSQL, the foreign tables, the range types, the comments of columns, and the division of a table into parts: all its rows go into one table. - In SQL Server, the table types, and the indexes of other kinds than the usual ones, such as columnstore and XML. > Try to restore a copy before you depend on it. For what is not in it, use the backup tool of your server or, in PostgreSQL, [pg_dump](/totalsql/latest/guides/pg-dump/). The rows are read table by table, not at one instant. If others write in the database while you copy it, the tables may not agree with each other. ## Restore it For a file of up to 8 MB: 1. Make an empty database, and open it in TotalSQL. 2. In a query, press **Open a SQL file…** and choose the copy. 3. Press **Run**, and confirm. A larger file does not fit in the editor. Run it with the tool of your database: `psql`, `mysql`, `sqlcmd` or `sqlite3`. For example, in PostgreSQL: ```bash psql --dbname=shop_copy --file=shop.sql ``` ## If restoring fails It stops at the first error, and what ran before stays. Correct the cause, make the empty database again and start from the beginning of the file. In MySQL, MariaDB and SQLite, the file turns off the check of the relations while the rows go in, and turns it on at its end. If it stops half way, close the connection and open it again before you go on. --- title: Copy PostgreSQL with pg_dump project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/pg-dump/ updated: 2026-12-02T15:40:26.075Z --- # Copy PostgreSQL with pg_dump > For a database of PostgreSQL, TotalSQL can write the copy with `pg_dump`, the tool of PostgreSQL itself, when your computer has it. ## Why use it Compared with [the copy by TotalSQL](/totalsql/latest/guides/copy-a-database/), the one by `pg_dump`: - has everything that the database holds, with its permissions; - takes the whole database at one instant, also while others use it; - can be a compressed archive, from which you restore everything or only some tables. ## Install pg_dump | System | How | | --- | --- | | macOS | With [Homebrew](https://brew.sh): `brew install libpq`. [Postgres.app](https://postgresapp.com) and the installer of [postgresql.org](https://www.postgresql.org/download/macosx/) have it too | | Windows | The installer of [postgresql.org](https://www.postgresql.org/download/windows/). "Command Line Tools" is enough | | Debian, Ubuntu | `sudo apt install postgresql-client` | | Fedora, RHEL | `sudo dnf install postgresql` | There is nothing to set up. TotalSQL looks for it in the usual places, and uses the newest if there are several. It must be of the same version as the server, or newer. ## Make the copy 1. Open the connection, and press **Export the database…** 2. In **What to write**, choose one: - **SQL file of everything, by pg_dump**, to read it or run it with `psql`; - **Archive for pg_restore (.dump), by pg_dump**, compressed. 3. Leave **With the rows of every table** on, or turn it off to have only the structure. 4. Press **Choose where…** **What to write** is there only when TotalSQL finds `pg_dump`. The copy goes by the same way as your connection, also through SSH, and you do not write the password again. ## Restore it Make an empty database first. For the SQL file: ```bash psql --dbname=shop_copy --file=shop.sql ``` > The SQL file of `pg_dump` does not run in a query of TotalSQL, because its rows are written in a way that only `psql` reads. For the archive, whole or one table: ```bash pg_restore --dbname=shop_copy shop.dump pg_restore --dbname=shop_copy --table=orders shop.dump ``` Add `--host`, `--port` and `--username` when the server is not the one of your computer. ## If it fails - **The pg_dump of this computer (…) is older than the server**: install the tools of the version of the server, or make the copy by TotalSQL, which still works. - A message that begins with **pg_dump:** comes from the tool itself. Your user may lack permission to read some table. --- title: Connect an AI project: TotalSQL version: Latest section: guides language: en license: url: https://totaljs.es/docs/totalsql/latest/guides/connect-an-ai/ updated: 2026-12-02T15:40:26.075Z --- # Connect an AI > TotalSQL has an MCP server, so an assistant on your computer can look at the database that you have in view and, if you allow it, propose changes that you confirm. ## Turn it on 1. Press **AI**. 2. Turn on **Let AI clients connect**. 3. Copy what your client needs. The dialog has it ready for Claude Code, for Claude Desktop, and for Cursor and other MCP clients. The address is `http://127.0.0.1:7240/mcp`. If that port is in use, TotalSQL takes the next free one, up to 7249, and the dialog has the right address. The server is off until you turn it on. It listens only on this computer, and only while TotalSQL is open. It asks for a token, which is kept in the secure store of your system. With **New token…**, the clients that have the old one stop working until you give them the new one. > Whoever has the token can read the database that you have in view. Give it only to your AI clients. ## What it can see The assistant works with the connection in view, and follows you when you go to another. It sees no other connection, and never your passwords. When you are in the list of connections, it has no database. What it reads goes to the assistant, and to the company behind it if it does not run on your computer. ## The tools | Tool | What it does | | --- | --- | | `Database_info` | The kind, the version, the environment and the care level | | `Tables_list` | The tables and views, with their estimated rows | | `Table_describe` | The structure of a table | | `Table_rows` | Up to 200 rows of a table, with filters | | `Objects_list` | Functions, sequences, triggers and the rest | | `Object_definition` | The SQL that makes one of them | | `Query_run` | Runs SQL, and gives up to 200 rows for each statement | ## Changes At first, only statements that read run. To let the assistant propose others, turn on **Let it propose changes**. Then each request that changes data or structure opens **An AI assistant wants to run this**, with its statements. Press **Run** or **Do not run**. Closing the dialog is a no, and so is leaving it for three minutes. It asks with any [care level](/totalsql/latest/guides/care/), and a read-only connection still refuses. A `SELECT` that changes data by a function it calls counts as a change too. In PostgreSQL, MySQL, MariaDB and SQLite the database itself refuses it until you say yes. In MySQL and MariaDB, while you have a transaction open or tables locked in the connection, the assistant cannot read: end it, or free them, first. **What assistants did** has the last calls since you opened TotalSQL. The statements also go to the **History** of the connection. ## Code mode For work of several steps, the assistant can write one script instead of calling the tools one by one, and only its result goes back to the model. Download the client, which needs Node.js 18 or newer: ```bash curl -H 'Authorization: Bearer YOUR_TOKEN' 'http://127.0.0.1:7240/mcp/client.js' -o totalsql.js ``` It has a function for each tool: ```javascript const api = require('./totalsql.js')('YOUR_TOKEN'); (async function() { const tables = await api.Tables_list(); const result = await api.Query_run({ sql: 'SELECT count(*) FROM orders' }); console.log(tables.schemas.length, result.statements[0].rows); })(); ``` A function that fails throws an error with the message of TotalSQL. The dialog has this code with your address and your token. --- title: Keyboard shortcuts project: TotalSQL version: Latest section: reference language: en license: url: https://totaljs.es/docs/totalsql/latest/reference/shortcuts/ updated: 2026-12-02T15:40:26.075Z --- # Keyboard shortcuts > The keys of TotalSQL, for the Mac and for Windows and Linux. ## In the window | Action | Mac | Windows and Linux | | --- | --- | --- | | New query, in an open connection | ⌘T | Ctrl+T | | Close the tab in front. With none, the connection, and then the window | ⌘W | | | Close the window | ⇧⌘W | Alt+F4 | | Close a dialog or a menu | Esc | Esc | Before something that is not saved is lost, TotalSQL asks. ## In a query | Action | Mac | Windows and Linux | | --- | --- | --- | | Run the selection, or everything | ⌘↵ | Ctrl+Enter | | Offer words and tables | ⌥I or ⌃Space | Ctrl+Space | | Take the word offered | ↵ | Enter | | Comment the lines, or take the comment away | ⌘/ | Ctrl+/ | | Move the line up or down | ⌥↑ and ⌥↓ | Alt+↑ and Alt+↓ | | Copy the line above or below | ⇧⌥↑ and ⇧⌥↓ | Shift+Alt+↑ and Shift+Alt+↓ | | Delete the line | ⇧⌘K | Ctrl+Shift+K | | Indent the lines, or the opposite | Tab and ⇧Tab | Tab and Shift+Tab | | Undo | ⌘Z | Ctrl+Z | | Redo | ⇧⌘Z | Ctrl+Y | Tab writes in the editor. To leave the editor with the keyboard, press Esc and then Tab. ## In the rows Press Tab to enter the grid. It has one active cell, or one active column name. | Action | Mac | Windows and Linux | | --- | --- | --- | | Move a cell | The arrows | The arrows | | Go to the first or last row | ⌘↑ and ⌘↓ | Ctrl+↑ and Ctrl+↓ | | Go to the first or last column | ⌘← and ⌘→ | Ctrl+← and Ctrl+→ | | Go to the first or last column | Home and End | Home and End | | Go to the first or last cell of all | ⌘Home and ⌘End | Ctrl+Home and Ctrl+End | | Move a screen | Page Up and Page Down | Page Up and Page Down | | [Change the value](/totalsql/latest/guides/edit-rows/#change-a-value) | ↵ or F2 | Enter or F2 | | Copy the value | ⌘C | Ctrl+C | | Open the menu of the cell | ⇧F10 | Shift+F10 or the menu key | ## In the names of the columns Go up from the first row to reach them. | Action | Mac | Windows and Linux | | --- | --- | --- | | Sort by the column, in a table | ↵ | Enter | | Move the column | ⌥← and ⌥→ | Alt+← and Alt+→ | | Make it narrower or wider | ⇧⌥← and ⇧⌥→ | Shift+Alt+← and Shift+Alt+→ | The last two also work from any cell of the column. --- title: Problems and answers project: TotalSQL version: Latest section: faq language: en license: url: https://totaljs.es/docs/totalsql/latest/faq/problems/ updated: 2026-12-02T15:40:26.075Z --- # Problems and answers > What the messages of TotalSQL mean, and what to do. ## It does not connect | Message | What to do | | --- | --- | | **The server cannot be reached** or **The server does not answer** | Check the address, the port and the firewall. Many databases listen only to their own computer: [go through SSH](/totalsql/latest/guides/secure-connections/#connect-through-an-ssh-server) | | **The server did not accept the sign-in** | Check the user and the password. The rest of the message is of the server | | **The server needs a password** | Write it in the connection | | **The server does not offer TLS** | It has no encryption. Choose **Not encrypted**, and go [through SSH](/totalsql/latest/guides/secure-connections/#connect-through-an-ssh-server) if it is another computer | | **The secure connection failed** | The certificate is not valid for that name. Choose [another encryption](/totalsql/latest/guides/secure-connections/#encryption) | | **This file is not a SQLite database** | It is another kind of file, or an encrypted one, which TotalSQL does not open | | **There is no database file at …** | Check the path | ## SSH does not let me through | Message | What to do | | --- | --- | | **The SSH server could not reach …** | Give the name and the port that the database has as seen from that server, not from your computer | | **It is not a running Docker container …** | The container is stopped, has another name, or the SSH user may not ask Docker | | **The SSH server does not allow tunnels** | Its administrator can allow them with `AllowTcpForwarding` | | **The private key needs its passphrase, or it cannot be read** | Write the passphrase, or check the path of the key | | **The SSH agent is not running** | Start the agent, or choose **Private key**. On Windows, it is the service **OpenSSH Authentication Agent** | ## "The connection to the server was lost" The server closed it, or the network changed. [Close the connection and open it again](/totalsql/latest/guides/connections/#when-the-connection-is-lost). ## "The secure store of the system is not available" TotalSQL cannot keep the password. On Linux it needs a service that keeps secrets, such as GNOME Keyring or KWallet. Meanwhile, turn off **Keep the passwords in the keychain of the system, so it does not ask again**. ## I cannot change the rows The line at the bottom says why. [When rows cannot be changed](/totalsql/latest/guides/edit-rows/#when-rows-cannot-be-changed) explains each reason. ## "A row changed or went away since it was read, so nothing was saved" The row is not there any more, or its key is another. Press **Reload the rows**, and make your changes again. ## "This file is larger than 8 MB: too much for the editor" Run it with the tool of your database. [Restore it](/totalsql/latest/guides/copy-a-database/#restore-it) has an example. ## "This statement reads, but something it calls changes data" A function that your `SELECT` calls writes in the database, and the connection is read-only. [How a statement is judged](/totalsql/latest/guides/care/#how-a-statement-is-judged) explains it. ## "This result is gone. Run the query again." TotalSQL keeps the last 64 results in memory. The older ones go. ## The AI client does not connect Look in **AI** that **Let AI clients connect** is on, and compare the address: the port changes if another program has 7240. After a new token, give it to your client. [Connect an AI](/totalsql/latest/guides/connect-an-ai/) has the steps. ## What TotalSQL keeps, and where Your connections, the history, the saved queries and the trusted SSH servers are in the file `app.db` of the folder of the app: | System | Folder | | --- | --- | | macOS | `~/Library/Application Support/es.totaljs.apps.totalsql` | | Windows | `%APPDATA%\es.totaljs.apps.totalsql` | | Linux | `~/.local/share/es.totaljs.apps.totalsql` | The passwords are not in it: they are in the secure store of your system. ## What TotalSQL knows about me Nothing is collected about you. TotalSQL connects only to the databases and the SSH servers that you add. [Privacy](/totaldesktop/latest/guides/privacy/) has the details. ## Something else [Report the problem](https://github.com/totaljs-es/totaljs-desktop/issues/new?template=problem.yml) with the version of TotalSQL, your system and the kind of database.