Postgres syntax randomness

  • Ensure System environment variable is set correctly to the location of psql.exe
    C:\Program Files\PostgreSQL\9.3\bin
    
  • Connect and create some dummy db
  • psql -U postgres -h localhost
    psql (9.3.4)
    WARNING: Console code page (437) differs from Windows code
             8-bit characters might not work correctly. See psq
             page "Notes for Windows users" for details.
    Type "help" for help.
    
    postgres=# create database anthonydb;
    CREATE DATABASE
    
  • List Dbs
  • postgres=# \l
                                                     List of da
       Name    |  Owner   | Encoding |          Collate
               |   Access privileges
    -----------+----------+----------+-------------------------
    -----------+-----------------------
     anthonydb | postgres | UTF8     | English_United States.12
    tates.1252 |
     postgres  | postgres | UTF8     | English_United States.12
    tates.1252 |
     template0 | postgres | UTF8     | English_United States.12
    tates.1252 | =c/postgres          +
               |          |          |
               | postgres=CTc/postgres
     template1 | postgres | UTF8     | English_United States.12
    tates.1252 | =c/postgres          +
               |          |          |
               | postgres=CTc/postgres
    (4 rows)
    
    
  • Create some dummy schema, table and user
  • postgres=# create user admin with password 'admin';
    postgres=# drop database mydb;
    postgres=# \c anthonydb;
    
    
    anthonydb=# create schema friends;
    
    anthonydb=# create table friends.tableTest (fistname CHAR (15), lastname CHAR(20
    ));
    CREATE TABLE
    
    anthonydb=# \d friends.tableTest;
          Table "friends.tabletest"
      Column  |     Type      | Modifiers
    ----------+---------------+-----------
     fistname | character(15) |
     lastname | character(20) |
    
    
    
    anthonydb=# insert into friends.tableTest values ('who cares', 'never mind');
    
    
  • JDBC connection URL
  •   jdbc:postgresql://<host>:<port>/<dbname>?username=<username>&password=<password>
      
    So
      export DATABASE_URL=jdbc:postgresql://localhost:5432/anthonydb?username=admin&password=admin  (linux)
      SET DATABASE_URL=postgres://admin:admin@localhost:5432/anthonydb  (windows}
    
    

Published by anthonykuong

Anthony is a versatile Software professional with around 10 years of experience. He is a Full Stack developer experienced with clients in the Financial, Health and Supply Chain industries. He is experienced with MVC frameworks ( Spring Boot) , SPA frameworks ( Angular , VueJS), and also supports automated build deployments and packaging for development, qa, and production servers.. He has delivered rich user experience using Modern web technologies and techniques such are HTML5, CSS3, ECMAScript 6 (ES6)/ ECMAScript 2015, CSS pre-processors (SASS, Less), JavaScript build tools (Grunt, Gulp) , various UI Frameworks including AngularJS , Knockout JS , and CSS Frameworks including Bootstrap, and Foundation. He is adaptable to new technologies and frameworks. He is a rigorous, quality-conscious contributor with solid analytical skills. I can also be found on youtube - Youtube Channel: https://www.youtube.com/user/akuong/

Leave a comment