Skip to main content

Query editor

The query editor lets you run SQL against the connected PostgreSQL database.

Cocoding AI SQL query editor with query results and history
Run focused read queries to verify generated app data before asking for schema or UI changes.

Common query examples

SELECT * FROM bookings LIMIT 10;
SELECT status, COUNT(*)
FROM bookings
GROUP BY status
ORDER BY status;
SELECT rooms.name, rooms.price_per_night
FROM rooms
ORDER BY rooms.price_per_night DESC;

Run a query

  1. Open the database tool from the workspace.
  2. Choose Query.
  3. Write a focused SQL statement.
  4. Execute it.
  5. Review the result table.
  6. Save the query externally if it is useful for later testing.

Query workflow

Use the query editor as a verification tool:

  1. Confirm the table exists.
  2. Count records.
  3. Inspect recent rows.
  4. Check status values and ownership fields.
  5. Join related tables when a screen depends on relationships.
  6. Ask Cocoding AI to update the app only after you know which data is wrong.

Useful checks

GoalQuery pattern
Confirm records existselect count(*) from table_name;
Inspect latest recordsorder by created_at desc limit 20
Check status workflowselect status, count(*) from table_name group by status;
Verify relationshipsJoin child records to their parent record by ID.
Find empty fieldsFilter where important columns are null or empty.

Read-only recipes

SELECT COUNT(*) FROM bookings;
SELECT status, COUNT(*)
FROM payments
GROUP BY status;
SELECT b.id, b.status, u.email
FROM bookings b
JOIN users u ON u.id = b.user_id
ORDER BY b.created_at DESC
LIMIT 20;

Query safely

  • Start with SELECT queries.
  • Use LIMIT when inspecting large tables.
  • Avoid destructive statements unless you are in a test database.
  • Keep a copy of important data before bulk updates.
  • Avoid running copied SQL if you do not understand what it changes.
  • Do not paste production data exports into chat.

Keyboard shortcut

Use Cmd + Enter on macOS or Ctrl + Enter on Windows/Linux when the query editor supports quick execution.

Troubleshooting query results

SymptomWhat to check
Table does not existAsk Cocoding AI to create or run the migration, then refresh the database panel.
Empty resultConfirm filters, workspace, owner ID, and status values.
Permission errorCheck the connected database user and schema privileges.
Query is slowAdd LIMIT, filter by indexed columns, or ask for an index recommendation.
Preview still wrongPaste the query result summary and ask Cocoding AI to update the app query or component.