Skip to content

Instantly share code, notes, and snippets.

@mahmoudalnkeeb
Last active February 2, 2022 18:52
Show Gist options
  • Select an option

  • Save mahmoudalnkeeb/1cf6875bfc8a55a53930cf4207ae5a35 to your computer and use it in GitHub Desktop.

Select an option

Save mahmoudalnkeeb/1cf6875bfc8a55a53930cf4207ae5a35 to your computer and use it in GitHub Desktop.
contains PostgreSQL basic syntax

PostGres Basic Syntax

meta commnds

 \c connect
 \q exit
 \dt display table
 \l list of databases

create database

CREATE DATABASE my_database

create table

CREATE TABLE table_name(id SERIAL PRIMARY KEY,name VARCHAR(lenght),age integer,description text)

CRUD

C: 'create'
R: 'read'
U: 'update'
D: 'delete'

create

    INSERT INTO (table name) (colmuns) VALUES (columns values)

read

SELECT * FROM (table name)

update

UPDATE (table name) SET (column to update) WHERE condition

delete

DELETE FROM (table_name) WHERE condition

filters

  • WHERE

       specify condition to filter
    
  • LIMIT

      limit the N of responses
    
  • BETWEEN

      selects data between two values
    
  • LIKE

      identifies content that matches based on a patterns
    
  • IS NULL

      checks if value is null
    
  • ISNOTNULL

      checks if value is not null
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment