PostgreSQL is a powerful open source relational database. If you have worked with MySQL before, PostgreSQL will feel familiar but with additional enterprise features.
First install PostgreSQL using your package manager. On Ubuntu:
First install PostgreSQL using your package manager. On Ubuntu:
sudo apt install postgresqlOnce installed, check service status:
sudo systemctl status postgresqlSwitch to postgres user:
sudo -i -u postgresEnter PostgreSQL prompt:
psqlTo list databases:
\lTo create a new database:
CREATE DATABASE mydb;To connect to it:
\c mydbTo create a table:
CREATE TABLE users ( id SERIAL PRIMARY KEY, name TEXT, email TEXT );To insert data:
INSERT INTO users (name, email) VALUES ('John', '[john@example.com](mailto:john@example.com)');
To query data:
SELECT * FROM users;To exit:
\qPostgreSQL is reliable, standards compliant, and production ready.
Disclaimer: If you follow the information here, there is no warranty, I am not liable if it deletes your data, gets you hacked, burns your house down or anything else. If you follow the information contained here you do so entirely at your own risk. My views and opinions are my own and not necessarily represent the views of my employer. © Raheel Hameed and www.raheelhameed.com, 2017. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to author and this website with appropriate and specific direction to the original content.
Disclaimer: If you follow the information here, there is no warranty, I am not liable if it deletes your data, gets you hacked, burns your house down or anything else. If you follow the information contained here you do so entirely at your own risk. My views and opinions are my own and not necessarily represent the views of my current or former employers. © Raheel Hameed and www.raheelhameed.com, 2017. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given to author and this website with appropriate and specific direction to the original content.
Comments
Post a Comment