Postgres: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 12: | Line 12: | ||
psql | psql | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Quiting.. | |||
<syntaxhighlight "psql"> | <syntaxhighlight "psql"> | ||
\q | \q | ||
</syntaxhighlight> | </syntaxhighlight> | ||
=Useful commands= | |||
<syntaxhighlight "psql"> | |||
# Show users | |||
\du | |||
# Show databases | |||
\l | |||
# Show tables | |||
\dt | |||
# Create database | |||
CREATE DATABASE testdb; | |||
# Use database | |||
\c testdb | |||
# Create Table | |||
# Describe the Table | |||
\d test_table | |||
# Create Index | |||
# Command History | |||
\s | |||
</syntaxhighlight> | |||
=Create Super User= | =Create Super User= |
Revision as of 07:18, 12 June 2021
Introduction
This is a page for keeping track of using postgres
Install
Nice and easy lemon squeezy
sudo apt install postgresql postgresql-contrib
Getting to CLI
Login and envoke the CLI
sudo -i -u postgres
psql
Quiting..
\q
Useful commands
# Show users
\du
# Show databases
\l
# Show tables
\dt
# Create database
CREATE DATABASE testdb;
# Use database
\c testdb
# Create Table
# Describe the Table
\d test_table
# Create Index
# Command History
\s