4,348
edits
m →Usage |
mNo edit summary |
||
(6 intermediate revisions by the same user not shown) | |||
Line 88: | Line 88: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
$ | $ createdb -O puser appdb | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= Usage = | = Usage = | ||
Log into PostgreSQL console using a specific user and DB | |||
<syntaxhighlight lang="bash"> | |||
$ sudo -iu puser | |||
$ psql -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 || Connection information || Get current connection information | ||
|- | |- | ||
| | | class="cli" | \d || List || List tables, views, and sequences | ||
|- | |||
| class="cli" | \dt || List tables || | |||
|} | |} | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= Resources = | = Resources = | ||
[[Introduction to PostgreSQL for MySQL Users]] | [[Introduction to PostgreSQL for MySQL Users]] |