SQL Reference
GhostSQL supports a broad subset of PostgreSQL-compatible SQL, including arithmetic and advanced filtering.
Expressions & Operators
Arithmetic
GhostSQL supports standard arithmetic operators in SELECT and WHERE clauses:
- + (Addition)
- - (Subtraction)
- * (Multiplication)
- / (Division)
Example: SELECT (salary + 5000) * 1.1 AS bonus FROM employees;
Comparison & Pattern Matching
=,!=,<,>,<=,>=IN (val1, val2, ...)LIKE 'pattern'(use%for any string,_for single character)
Example: SELECT * FROM users WHERE name LIKE 'A%' AND id IN (1, 10, 100);
Data Manipulation (DML)
INSERT
Response tag:INSERT 0 n (PostgreSQL standard, where n is the row count).
UPDATE
DELETE
TRUNCATE
Data Definition (DDL)
CREATE TABLE
The executing role becomes the owner of the table and has full access automatically.ALTER TABLE
ALTER TABLE table_name ADD COLUMN column_name data_type;
ALTER TABLE table_name ENABLE ROW LEVEL SECURITY;
DROP TABLE
Access Control (DCL)
CREATE ROLE
CREATE ROLE rolename WITH LOGIN PASSWORD 'pass';
CREATE ROLE rolename WITH LOGIN PASSWORD 'pass' SUPERUSER;
DROP ROLE
GRANT
-- Database-level
GRANT CONNECT ON DATABASE dbname TO rolename;
GRANT CREATE ON DATABASE dbname TO rolename;
-- Table-level
GRANT SELECT ON TABLE tablename TO rolename;
GRANT INSERT, UPDATE, DELETE ON TABLE tablename TO rolename;
GRANT ALL PRIVILEGES ON TABLE tablename TO rolename;
REVOKE
CREATE POLICY (Row-Level Security)
Transaction Control
GhostSQL accepts but does not yet fully implement ACID transactions. These statements are parsed and accepted as no-ops:
Session Variables
Metadata & Discovery
SHOW TABLES
List all tables in the current database.