portmid.blogg.se

Mysql to postgresql cheat sheet
Mysql to postgresql cheat sheet











mysql to postgresql cheat sheet
  1. #Mysql to postgresql cheat sheet pdf
  2. #Mysql to postgresql cheat sheet code
  3. #Mysql to postgresql cheat sheet password
  4. #Mysql to postgresql cheat sheet download

#Mysql to postgresql cheat sheet code

WHERE column LIKE '%value%' Code language: SQL (Structured Query Language) ( sql ) Query data using the LIKE operator: SELECT * FROM table_name Query data from a table with a filter: SELECT *įROM table WHERE condition Code language: SQL (Structured Query Language) ( sql )Īssign an alias to a column in the result set: SELECT column_1 AS new_column_1.

mysql to postgresql cheat sheet

Query data and select only unique rows: SELECT DISTINCT ( column) Query data from specified columns of all rows in a table: SELECT column_listįROM table Code language: SQL (Structured Query Language) ( sql ) Query all data from a table: SELECT * FROM table_name Code language: SQL (Structured Query Language) ( sql ) Removing a specified index from a table DROP INDEX index_name Code language: SQL (Structured Query Language) ( sql ) Querying data from tables ON table ( column.) Code language: SQL (Structured Query Language) ( sql ) Rename a view: ALTER VIEW view_name RENAME TO new_name Code language: SQL (Structured Query Language) ( sql ) Managing indexesĬreating an index with the specified name on a table CREATE INDEX index_name Refresh a materialized view: REFRESH MATERIALIZED VIEW CONCURRENTLY view_name Ĭode language: SQL (Structured Query Language) ( sql )ĭrop a view: DROP VIEW view_name Code language: SQL (Structured Query Language) ( sql )ĭrop a materialized view: DROP MATERIALIZED VIEW view_name Code language: SQL (Structured Query Language) ( sql ) ALTER TABLE table_name RENAME TO new_table_name Code language: SQL (Structured Query Language) ( sql )ĭrop a table and its dependent objects: DROP TABLE table_name CASCADE Code language: SQL (Structured Query Language) ( sql ) Managing viewsĬreate a view: CREATE OR REPLACE view_name AS query Code language: SQL (Structured Query Language) ( sql )Ĭreate a recursive view: CREATE RECURSIVE VIEW view_name(column_list) AS SELECT column_list Code language: SQL (Structured Query Language) ( sql )Ĭreate a materialized view: CREATE MATERIALIZED VIEW view_nameĪS query WITH DATA Code language: SQL (Structured Query Language) ( sql ) ALTER TABLE table_nameĭROP CONSTRAINT primary_key_constraint_name Code language: SQL (Structured Query Language) ( sql ) ALTER TABLE table_name ADD PRIMARY KEY (column.) Set or remove a default value for a column: ALTER TABLE table_name ALTER COLUMN Code language: SQL (Structured Query Language) ( sql )Īdd a primary key to a table. Rename a column: ALTER TABLE table_name RENAME column_name TO new_column_name Code language: SQL (Structured Query Language) ( sql ) ) Code language: SQL (Structured Query Language) ( sql )Īdd a new column to a table: ALTER TABLE table_name ADD COLUMN new_column_name TYPE Code language: SQL (Structured Query Language) ( sql )ĭrop a column in a table: ALTER TABLE table_name DROP COLUMN column_name Code language: SQL (Structured Query Language) ( sql )

#Mysql to postgresql cheat sheet password

Show query output in the pretty-format: \xĬreate a new role: CREATE ROLE role_name Ĭreate a new role with a username and password: CREATE ROLE username NOINHERIT LOGIN PASSWORD password Ĭhange role for the current session to the new_role: SET ROLE new_role Īllow role_1 to set its role as role_2: GRANT role_2 TO role_1 Code language: SQL (Structured Query Language) ( sql ) Managing databasesĬreate a new database: CREATE DATABASE db_name Code language: SQL (Structured Query Language) ( sql )ĭelete a database permanently: DROP DATABASE db_name Code language: SQL (Structured Query Language) ( sql ) Managing tablesĬreate a new table or a temporary table CREATE TABLE table_name( Show a stored procedure or function code: \df+ function_name Or to get more information on tables in the current database: \dt+ List all views: \dv Code language: SQL (Structured Query Language) ( sql )

mysql to postgresql cheat sheet

List all stored procedures and functions: \df List all schemas: \dn Code language: SQL (Structured Query Language) ( sql ) List all databases in the PostgreSQL database server \l Code language: SQL (Structured Query Language) ( sql ) You are now connected to database "dvdrental" as user "postgres".

#Mysql to postgresql cheat sheet download

You can download and print it out for a quick reference to the most commonly used statements in PostgreSQL:ĭownload PostgreSQL Cheat Sheet PostgreSQL commandsĪccess the PostgreSQL server from psql with a specific user: psql -U Code language: CSS ( css )įor example, the following command uses the postgres user to access the PostgreSQL database server: psql -U postgres Code language: SQL (Structured Query Language) ( sql )Ĭonnect to a specific database: \c database_name įor example, the following command connects to the dvdrental database: \c dvdrental

#Mysql to postgresql cheat sheet pdf

We provide you with a 3-page PostgreSQL cheat sheet in PDF format.

mysql to postgresql cheat sheet

The PostgreSQL cheat sheet provides you with the common PostgreSQL commands and statements that enable you to work with PostgreSQL quickly and effectively.













Mysql to postgresql cheat sheet