Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dougsland/postgres-by-example
postgres sqls
https://github.com/dougsland/postgres-by-example
Last synced: 4 days ago
JSON representation
postgres sqls
- Host: GitHub
- URL: https://github.com/dougsland/postgres-by-example
- Owner: dougsland
- Created: 2017-05-18T19:18:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-19T13:46:36.000Z (over 7 years ago)
- Last Synced: 2024-11-18T07:14:09.773Z (about 1 month ago)
- Language: PLpgSQL
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Concepts
database is a collection of tables and functions. A table consists of
a list of records (rows) with fixed number of fields or columns.# Keys
Primary keys is a unique key in the table, it is the identifier of record (row).
Foreign keys# postgres-by-example
postgres sqls$ psql --command SQLCOMMAND
Specifies that psql is to execute one command string, command, and then exit.$ psql --file example.sql
Use the file filename as the source of commands instead of reading commands interactively.$ psql -h hostname -p 5432 -d dbname -U username
Connect to hostname, port 5432$ psql -l
List all databases# Meta commands
\password
Change password
postgres=# \password\timing
Execution timing
postgres=# \timing\h
Provides help on specific SQL commands
postgres=# \h CREATE\?
Provides help on psql meta-commands\q
Quit\dv
List views\d view-name
Show view definition# WHERE operators
| Operator | Description |
|----------|------------------------------|
| = | Equality |
| <> | Non Equality |
| != | Non Equality |
| < | Less than |
| <= | Less than or equal to |
| > | Greater than |
| >= | Greator than or equal to |
| BETWEEN | Between two specified values |
| IS NULL | Is a NULL value |
| ( ) | To group operators, priority |# Types
**timestamptz**
Accepted as an abbreviation for timestamp with time zone
https://www.postgresql.org/docs/9.1/static/datatype-datetime.html**VARCHAR(N)**
**uuid**
**integer**
# Shell Commands
createdb
Create database, wrapper for CREATE DATABASEdropdb
Drop database, wrapper for DROP DATABASE# Graphical administration tools
- pgAdmin3
- phpPgAdmin