Created
May 27, 2020 19:20
-
-
Save kamipo/7806543df5917b08bd598b9d884aa93a to your computer and use it in GitHub Desktop.
PostgreSQL 101
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```bash | |
brew install postgresql | |
pg_config | |
mkdir -p /usr/local/var/postgres | |
initdb /usr/local/var/postgres -E utf8 | |
vi /usr/local/var/postgres/postgresql.conf | |
postgres -D /usr/local/var/postgres | |
# or | |
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start | |
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log stop | |
tail -F /usr/local/var/postgres/server.log | |
createuser --help | |
createuser -h 127.0.0.1 -s -r postgres | |
psql --help | |
psql -U postgres | |
``` | |
### postgresql command for mysql users | |
* show databases; | |
* ¥l | |
* select * from information_schema.schemata; | |
* use dbname | |
* ¥c dbname | |
* show tables; | |
* ¥dt | |
* ¥z | |
* show table status from dbname; | |
* select * from information_schema.tables where table_schema='artest_mysql_development'; | |
* show create table [dbname.]tblname; | |
* ### postgresql ### | |
* select * from information_schema.columns | |
where table_catalog = 'dbname' | |
and table_name = 'accounts' order by ordinal_position; | |
* ### mysql ### | |
* select * from information_schema.columns | |
where table_schema = 'dbname' | |
and table_name = 'accounts' order by ordinal_position; | |
* show full columns from [dbname.]tblname; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment