Truncate a table on cascade and reset all hierarchic sequences with 1
TRUNCATE schema.mytable RESTART IDENTITY CASCADE;
TRUNCATE schema.mytable RESTART IDENTITY CASCADE;
This function written in plpgsql splits the string according to the separator and returns the last part. If the separator is not present in the string this function returns an empty string. CREATE OR REPLACE…
List of useful commands for working with ENUM in postgresql. Create an enum: CREATE TYPE languages AS ENUM (‘python’, ‘php’, ‘java’); Adding an element to an enum: ALTER TYPE languages ADD VALUE ‘go’;ALTER TYPE languages…
ALTER SEQUENCE mytable_id_seq RESTART WITH 1 If at the same time resetting a autoincrement field in postgresql we also want to empty the table, you can run this command: TRUNCATE TABLE mytable RESTART IDENTITY;
To enable remote access to a postgresql database from a computer or server, in Ubuntu server, first we need to know the ip of the computer in question, for example 92.58.201.162. Then, from the terminal,…
Install and Update Pip3: sudo apt install python3-pip sudo pip3 install –upgrade pip sudo pip3 install –upgrade setuptools Now launch the installation command for psycopg2: sudo pip3 install psycopg2 If it returns the following error:…