Skip to content

Latest commit

 

History

History
83 lines (45 loc) · 1.59 KB

postgres.rst

File metadata and controls

83 lines (45 loc) · 1.59 KB

PostgreSQL

En MacOS instalamos Postgres.app

Para usar la linea de comandos, agregamos al path

$ echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
$ psql -p5432
user=# \q
$ psql -p5432 -d postgres

Listar todas las bases de datos

postgres=# \list

Listar todas las tablas en la base datos

postgres=# \dt

Cambiar la base de datos

postgres=# \connect otherdb

Listar todos los usuarios

postgres=# \du

Crear un usuario similar a tu nombre de usuario.

$ sudo su - postgres -c "createuser -s $USER"

Because the role login is the same as your unix login unix sockets can be use without a password.

You can see at any time which database is currently selected using

mysql> SELECT DATABASE();
mysql> CREATE DATABASE databasename;
mysql> CREATE USER 'user'@'localhost' IDENTIFIED BY 'some_password';
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
    -> ON cons_cmo.*
    -> TO 'user'@'localhost';
mysql> DESCRIBE table;
mysql> SELECT * FROM table;

Python

Referencias

Postgres.app

PostgreSQL Documentation

Postgres Guide

Mastering PostgreSQL in Application Development