Adding a new auto increment column to a table in postgres

postgresql postgres sql 5 months, 2 weeks ago
-- New versions of postgres -- adding as primary key ALTER TABLE my_schema.my_table ADD COLUMN id SERIAL PRIMARY KEY; --without primary key aslo you can use ALTER TABLE my_schema.my_table ADD COLUMN id SERIAL -- For old versions ALTER TABLE my_table ADD COLUMN id INTEGER; CREATE SEQUENCE my_id_seq OWNED BY; ALTER TABLE my_table ALTER COLUMN id SET DEFAULT nextval('my_id_seq'); UPDATE my_table SET id = nextval('my_id_seq');
Posted By
Move a table to other schema in Postgres
ALTER TABLE table_name SET SCHEMA new_sc
sql postgresql
Drop table in Sql
Drop table Table_name;
sql mysql
sonia shaik
how to print star using sql
DECLARE @var int               
SELECT @var = 5 
WHILE @var >0
sql printing pattern my sql
sonia shaik
decode (oracle) equivale in postgres
Simple Case:
case search-expression
    WHEN expression [, expression [ ... 
sql postgres oracle
sonia shaik
nvl (oracle) equivalent in postgres
COALESCE(value [, ...])
The COALESCE function accepts an unlimit
It returns the first argument that is no
sql postgres oracle
sonia shaik
PostgreSQL CONCAT_WS function
   concat_ws (column1,column2) AS new_co
sql concat_ws
How to connect to PostgreSQL database and dis
import psycopg2

conn = psycopg2.connect(host="localhost"
python psycopg2 postgresql
Connect to PostgreSQL in c# applications usin
using System.Text;
using System.Threading.Tasks;
using IronPython.Hosting;
c# csharp postgresql npgsql
How to stop the PostgreSQL manually?
show data_directory;   //To see the dire

pg_ctl -D /var/lib/postgresql/data stop 
manual stop postgresql mysql
How to delete SEQUENCE in postgresql
drop sequence sequence_name;
sequence postgresql mysql
How to copy a table from one database to anot
pg_dump -U user1 db_name_old_db | psql -
database postgresql copy table mysql