4,461
edits
m →Usage |
m →Usage |
||
Line 93: | Line 93: | ||
= Usage = | = Usage = | ||
Log into PostgreSQL console using a specific user and DB | |||
<syntaxhighlight lang="bash"> | |||
$ sudo -iu puser | |||
$ sudo -d appdata -U puser | |||
</syntaxhighlight> | |||
Create a new table | |||
<syntaxhighlight lang="psql"> | |||
puser=> CREATE TABLE demo( | |||
id serial PRIMARY KEY, | |||
email VARCHAR (100) UNIQUE NOT NULL, | |||
name VARCHAR (50) UNIQUE NOT NULL | |||
); | |||
</syntaxhighlight> | |||
{| class="wikitable sortable" | {| class="wikitable sortable" | ||
|+ PostgreSQL | |+ PostgreSQL console commands | ||
|- | |- | ||
! Command !! Action !! Description or Notes | ! Command !! Action !! Description or Notes | ||
Line 101: | Line 119: | ||
| class="cli" | \q || Quit || | | class="cli" | \q || Quit || | ||
|- | |- | ||
| | | class="cli" | \conninfo || Get connection information || | ||
|- | |- | ||
| Example || Example || Example | | Example || Example || Example | ||
|} | |} | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> |