SQL Commands: Difference between revisions
Jump to navigation
Jump to search
(→GRANT) |
|||
| (14 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
= Functions = | = Common Operations = | ||
== Functions == | |||
{| class="wikitable" | {| class="wikitable" | ||
! || Postgres || MariaDB || SQLite | ! || Postgres || MariaDB || SQLite | ||
|- | |- | ||
| | | Today | ||
| <syntaxhighlight lang="sql"></syntaxhighlight> | | <syntaxhighlight lang="sql"></syntaxhighlight> | ||
| <syntaxhighlight lang="sql"></syntaxhighlight> | | <syntaxhighlight lang="sql"></syntaxhighlight> | ||
| Line 10: | Line 12: | ||
|} | |} | ||
== Visiting == | |||
= Visiting = | |||
| Line 18: | Line 19: | ||
|- | |- | ||
| List tables | | List tables | ||
| <syntaxhighlight lang="sql"></syntaxhighlight> | | <pre></pre> | ||
| <syntaxhighlight lang="sql"></syntaxhighlight> | | <pre>show tables;</pre> | ||
| <syntaxhighlight lang="sql"></syntaxhighlight> | | <pre>.tables</pre> | ||
|} | |||
== CREATE USER == | |||
{| class="wikitable" | |||
! || Postgres || MariaDB | |||
|- | |||
| create user | |||
| <syntaxhighlight lang="sql"> | |||
CREATE USER username WITH PASSWORD 'your_password'; | |||
</syntaxhighlight> | |||
| <syntaxhighlight lang="sql"> | |||
</syntaxhighlight> | |||
|- | |||
| change password | |||
| <syntaxhighlight lang="sql"> | |||
</syntaxhighlight> | |||
| <syntaxhighlight lang="sql"> | |||
</syntaxhighlight> | |||
|} | |||
== GRANT == | |||
{| class="wikitable" | |||
! || Postgres || MariaDB | |||
|- | |||
| on database to user | |||
| <syntaxhighlight lang="sql"> | |||
GRANT ALL PRIVILEGES | |||
ON DATABASE operation_center | |||
TO db_user; | |||
</syntaxhighlight> | |||
| <syntaxhighlight lang="sql"> | |||
</syntaxhighlight> | |||
|- | |||
| on table to user | |||
| <syntaxhighlight lang="sql"> | |||
GRANT ALL PRIVILEGES | |||
ON ALL TABLES | |||
IN SCHEMA public | |||
TO db_user; | |||
</syntaxhighlight> | |||
| <syntaxhighlight lang="sql"> | |||
</syntaxhighlight> | |||
|} | |} | ||
Latest revision as of 03:03, 22 September 2025
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';
|