SQL Commands: Difference between revisions

From Fundamental Ramen
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
= Common Operations =
== PostgreSQL ==


== Functions ==
<syntaxhighlight lang="bash">
psql postgres://user@localhost:5432/dbname?sslmode=require -c 'SELECT 1'
</syntaxhighlight>
 
== Common Operations ==
 
=== Functions ===


{| class="wikitable"
{| class="wikitable"
Line 12: Line 18:
|}
|}


== Visiting ==
=== Visiting ===




Line 24: Line 30:
|}
|}


== CREATE USER ==
=== CREATE USER ===


{| class="wikitable"
{| class="wikitable"
Line 43: Line 49:
|}
|}


== GRANT ==
=== GRANT ===


{| class="wikitable"
{| class="wikitable"
Line 68: Line 74:
|}
|}


= SQLite 3 =
== SQLite 3 ==
{| class="wikitable"
{| class="wikitable"
! TODO || Command
! TODO || Command

Revision as of 08:37, 20 October 2026

PostgreSQL

psql postgres://user@localhost:5432/dbname?sslmode=require -c 'SELECT 1'

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';