PostgreSQL: Difference between revisions

22 bytes removed ,  13 October 2023
m
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 ||
|-
|-
| Example || Example || Example
| class="cli" | \conninfo || Get connection information ||
|-
|-
| Example || Example || Example
| Example || Example || Example
|}
|}
<code>\q</code>


<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>
<syntaxhighlight lang="bash">
</syntaxhighlight>


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">