OurSQL resources

SQL support & examples

Practical examples and SQL engine compatibility notes.

OurSQL runs real embedded MariaDB in your browser. Use MariaDB SQL. A syntax highlighter or formatter cannot add another database engine’s language.

Columns, keys and CHECK constraints

Keep a comma between column definitions. Put column options such as PRIMARY KEY before an inline CHECK. Commas inside DECIMAL(6,2), functions and strings belong to those expressions.

CREATE TABLE student_checks (
    student_id INT PRIMARY KEY
        CHECK (student_id BETWEEN 100 AND 999),
    student_name VARCHAR(10) NOT NULL,
    department VARCHAR(3),
    age INT CHECK (age >= 0)
);

INSERT INTO student_checks
    (student_id, student_name, department, age)
VALUES
    (100, 'Rahim', 'CSE', 20);

SELECT * FROM student_checks;

Select or create a database first. Use a new table name if this table already exists. IDs 100 and 999 are valid; 99 and 1000 are rejected. A nullable CHECK allows NULL, so use NOT NULL when a value is required.

Table-level constraints are also supported:

CREATE TABLE student_checks_named (
    student_id INT,
    student_name VARCHAR(10),
    PRIMARY KEY (student_id),
    CONSTRAINT valid_student_id
        CHECK (student_id BETWEEN 100 AND 999)
);

For a composite primary key, use one PRIMARY KEY (column_a, column_b). Do not declare two primary keys.

What the language supports

AreaSupport / boundary
Tables and constraintsMariaDB CREATE/ALTER TABLE, primary/composite keys, UNIQUE, NOT NULL, DEFAULT, CHECK and foreign keys. Check enforcement is tested with invalid INSERT and UPDATE operations.
QueriesSELECT, joins, grouping, subqueries, CTEs and window functions use the bundled MariaDB parser. Availability follows the embedded version displayed in the status bar.
Scripts and importsMultiple statements, comments, quotes, DELIMITER and session SQL modes. Triggers with custom delimiters work. Import compatibility options cover selected legacy modes, not arbitrary language conversion.
Other dialectsPostgreSQL, SQL Server, Oracle and SQLite are not separate engines here. Review types, auto-increment syntax, functions and client commands when porting SQL. SQL Server GO and SQLite PRAGMA are not MariaDB commands.
Embedded limitsThis build does not provide a normal server's users/grants, replication, stored routines or scheduled events. Inspect SHOW ENGINES and SHOW VARIABLES for actual runtime capabilities.
FormattingFormatting is optional. It preserves SQL tokens and quoted content. If parsing is unsupported or output would change tokens, the original text remains. Run still sends the original editor statement to MariaDB.

Export queries and results

After a successful execution, choose Export / Copy for a result or Export query + results for the whole run. Include the result, formatted query, or both in one report. Export captures the executed SQL and returned rows; it never reruns SQL or reads a later edit as the original query.

Choose PNG, JPG, SVG, styled HTML, TXT, SQL, Markdown or JSON. CSV contains one result table only. Colours/fonts are available in image and HTML reports; plain text formats cannot store those styles. The Print action can save a PDF through your browser.

Select a title/caption, theme, report font, image size/resolution and row range. Downloads include all selected returned rows, not just the visible page. Preview shows only the first 20 rows per statement. For very large or wide images, reduce the row range/resolution or choose HTML/CSV/JSON; no rows are silently discarded.

Clipboard text, rich HTML and PNG images need supported browser APIs and permission over HTTPS. JPG selection copies an image as PNG; SVG copying places source text on the clipboard. Download remains available if copying is blocked. Rich paste depends on the destination application.

SQL exports contain results as comments, not INSERT statements. Review queries before replaying them: they can modify data. Database context is the database at run start; native affected-row counts are retained in the execution snapshot.

Tabs, reload and the split workspace

Only one tab writes this browser database at a time. A second tab shows an OurSQL modal. Choose Continue in this tab to save and pause the active tab, or wait until it closes. Queries, imports or failed saves prevent an unsafe handover.

The footer’s Reload workspace action and refresh key events delivered to the page open a custom save/reload modal. Browser toolbar refresh and tab close cannot be paused with a custom web dialog. There is no native browser warning. SQL drafts are recovered in the same tab and database/table context after a reload; background database saves remain best effort if the browser is forcibly closed.

In SQL, click Show Crowfoot beside SQL. Drag the divider or use its arrow keys; Enter resets the split. Smaller screens stack the panes. The original Crowfoot tools remain intact and SQL transfers do not execute queries automatically.

Understanding an error

OurSQL retains the native error plus its number / SQLSTATE when supplied, identifies the failed statement and starting line, and offers targeted hints. A suggestion loads into the editor only when you choose it; it is never executed automatically. Import reports include the same guidance.

If earlier statements succeeded, they may already be committed. DDL such as CREATE TABLE cannot be undone by the rollback option. Correct only the failed statement where appropriate.

A raw “Unknown data type” message can be caused by a missing comma or misplaced column option, not just a missing type. Inspect the preceding definition too. Keep your complete SQL and downloaded import report when reporting a problem.

After updating OurSQL, close all old tabs and reopen so the installed offline version can activate. Do not clear browser data just to update: it contains your databases.

FULL OUTER JOIN and concept visualization

Open interactive concept visualization: compare input tables, matched/unmatched rows and logical query-processing steps using isolated demo data.

OurSQL 2.9.1 adds FULL JOIN / FULL OUTER JOIN compatibility for one SELECT joining two named tables/views with ON or USING. It preserves duplicates and NULL rows and applies filtering, grouping, ordering and LIMIT after combining both sides. The original editor text is retained.

SELECT p.name, t.title
FROM concept_people AS p
FULL OUTER JOIN concept_teams AS t ON p.team = t.id;

The visualization includes the required demo schema. Complex chained/nested joins, subqueries, bound ? placeholders, DDL wrappers and set operations around FULL JOIN need a native LEFT JOIN UNION ALL plus NOT EXISTS formulation. See release guide and test scope. SQL imports now use this same FULL JOIN compatibility. A successful imported SELECT reports its returned row count; open SQL to display/export its result table. Native PREPARE still uses MariaDB syntax. With SELECT * and ON, duplicate right-side column labels use alias.column so values remain visible.

The package includes automated semantic fixtures for W3Schools MySQL topics/functions and advanced queries, with exact per-query results in tests/w3schools-advanced-results.json. This does not certify every published example, dialect or parameter combination. Stored procedures and events remain unavailable in this embedded build.

Published examples and focused practice

Open the SQL compatibility audit for per-source/block execution outcomes, native errors, dialect boundaries and independent result comparisons. A successful execution alone is not complete semantic certification.

SQL → Focused mode enlarges the editor and hides navigation. Results can sit to the left, right or below; side panes resize with pointer or keyboard and stack on narrow screens.

MySQL ALTER TABLE … DROP CHECK is compiled to MariaDB DROP CONSTRAINT before execution, without retrying failed writes. Other vendor syntax requires explicit review; see release notes.

OurSQL 2.10.0 · MariaDB CREATE TABLE reference · Constraint reference