Introduction to access control

Creare database PostgreSQL

Darryl Reeves

Industry Assistant Professor, New York University

The default superuser

Muscle Image

  • postgres "superuser" role
  • Administers database
  • postgres privileges
    • Creating databases
    • Dropping databases
    • Inserting records
    • Deleting records
    • Dropping tables
  • postgres user should be used with care
Creare database PostgreSQL

Example: a personal finance database

  • Creation of finances database Finances Database
Creare database PostgreSQL

Example: a personal finance database

Database and Tables

Creare database PostgreSQL

Example: a personal finance database

  • Database is personal and not publicly accessible
  • User with restricted access should be created
  • User abilities:
    • Adding records
    • Querying records
    • Editing records
Creare database PostgreSQL

Creating new users

  • CREATE USER
    • Used to generate a new account
      CREATE USER newuser;
      
  • newuser can create tables in database
  • No access to tables created by other users
Creare database PostgreSQL

Setting user password

  • Passwords enhance security
  • No passwords by default
    CREATE USER newuser WITH PASSWORD 'secret';
    
ALTER USER newuser WITH PASSWORD 'new_password';
Creare database PostgreSQL

Let's practice!

Creare database PostgreSQL

Preparing Video For Download...