SQL Commands

From Fundamental Ramen
Revision as of 03:03, 22 September 2025 by Tacoball (talk | contribs) (→‎GRANT)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Common Operations

Functions

Postgres MariaDB SQLite
Today

Visiting

Postgres MariaDB SQLite
List tables

show tables;
.tables

CREATE USER

Postgres MariaDB
create user
CREATE USER username WITH PASSWORD 'your_password';
change password

GRANT

Postgres MariaDB
on database to user
GRANT ALL PRIVILEGES
  ON DATABASE operation_center
  TO db_user;
on table to user
GRANT ALL PRIVILEGES
  ON ALL TABLES
  IN SCHEMA public
  TO db_user;

SQLite 3

TODO Command
yyyymmdd to yyyy-mm-dd
SELECT printf('%s-%s-%s',
  SUBSTR(trading_date,1,4),
  SUBSTR(trading_date,5,2),
  SUBSTR(trading_date,7,2)
) FROM short_sell WHERE trading_date='20190605';