Search
 
SCRIPT & CODE EXAMPLE
 

SQL

what is postgresql

PostgreSQL is a powerful, open source object-relational database system. It has more than 15 years of active development phase and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness.

This tutorial will give you a quick start with PostgreSQL and make you comfortable with PostgreSQL programming.

What is PostgreSQL?
PostgreSQL (pronounced as post-gress-Q-L) is an open source relational database management system (DBMS) developed by a worldwide team of volunteers. PostgreSQL is not controlled by any corporation or other private entity and the source code is available free of charge.
Comment

postgres

Fun fact: "Postgres" has exactly as many characters as "Database"
Check for yourself!
Postgres --> 8 chars!
Database --> 8 chars!
Comment

postgreSQL

sudo mkdir -p /etc/paths.d &&
echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
Comment

postgreSQL

$ sudo -i -u postgres
Code language: Shell Session (shell)
Comment

Postgresql

# The bash function below utilizes the CLI tool psql to vacuum analyze tables
# in a single schema which can be identified by either passing the name of
# the schema as the first parameter to the function
# or setting the environment variable PG_SCHEMA:
#

vacuum_analyze_schema() {
    # vacuum analyze only the tables in the specified schema

    # postgres info can be supplied by either passing it as parameters to this
    # function, setting environment variables or a combination of the two
    local pg_schema="${1:-${PG_SCHEMA}}"
    local pg_db="${2:-${PG_DB}}"
    local pg_user="${3:-${PG_USER}}"
    local pg_host="${4:-${PG_HOST}}"

    echo "Vacuuming schema `${pg_schema}`:"

    # extract schema table names from psql output and put them in a bash array
    local psql_tbls="dt ${pg_schema}.*"
    local sed_str="s/${pg_schema}s+|s+(w+)s+|.*/1/p"
    local table_names=$( echo "${psql_tbls}" | psql -d "${pg_db}" -U "${pg_user}" -h "${pg_host}"  | sed -nr "${sed_str}" )
    local tables_array=( $( echo "${table_names}" | tr '
' ' ' ) )

    # loop through the table names creating and executing a vacuum
    # command for each one
    for t in "${tables_array[@]}"; do
        echo "doing table `${t}`..."
        psql -d "${pg_db}" -U "${pg_user}" -h "${pg_host}" 
            -c "VACUUM (ANALYZE) ${pg_schema}.${t};"
    done
}
Comment

postgres

# Use postgres/example user/password credentials
version: '3.1'

services:

  db:
    image: postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: example

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080
Comment

postgresql

CREATE OR REPLACE FUNCTION foo()
RETURNS void AS $$
BEGIN
  RAISE NOTICE 'Hello from void function';
END;
$$ LANGUAGE plpgsql;

-- direct call from SQL
SELECT foo();

-- in PLpgSQL
DO $$
BEGIN
  SELECT foo(); -- is not allowed
  PERFORM foo(); -- is ok
END;
$$;
Comment

postgres

$ sudo initdb --locale en_US.UTF-8 -D /var/lib/postgres/data
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgres/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Africa/Nairobi
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgres/data -l logfile start
Comment

PREVIOUS NEXT
Code Example
Sql :: db visualizer mssql 
Sql :: sqlite headers 
Sql :: how to type a blank discord messgae 
Sql :: sql column as header 
Sql :: postgresql inline table 
Sql :: reset sql primary key 
Sql :: oracle synonym procedure dblink 
Sql :: Call to undefined function mysql_query() in D:xampphtdocsimageindex.php:11 Stack trace: #0 {main} thrown in site:stackoverflow.com 
Sql :: cast find duration in sql 
Sql :: mysql max number not returning correct value 
Sql :: update user mysql 
Sql :: sintax checker sql 
Sql :: dbname+tablename 
Sql :: oracle user used size 
Sql :: oracle 11g forget password 
Sql :: database schema for mcqs type exam in sql 
Sql :: sqlalchemy sequence postgresql 
Sql :: sqlite 
Sql :: stored procedures example 
Sql :: oracle select partition 
Sql :: multiple values insert in sql 
Sql :: get month and year from date in mysql sequelize 
Sql :: select all users sql 
Sql :: sql statement show all emails with dome 
Csharp :: c# calcualte proccess 
Csharp :: c# create a text file 
Csharp :: use enter key unity 
Csharp :: wpf label text in center 
Csharp :: unity createassetmenu 
Csharp :: unity android quit application 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =