Adding a new auto increment column to a table in postgres

postgresql postgres sql 6 months, 4 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 my_table.id; ALTER TABLE my_table ALTER COLUMN id SET DEFAULT nextval('my_id_seq'); UPDATE my_table SET id = nextval('my_id_seq');
193
Posted By
Move a table to other schema in Postgres
ALTER TABLE table_name SET SCHEMA new_sc
sql postgresql
kishore_kumar
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
SELECT
   concat_ws (column1,column2) AS new_co
FROM
sql concat_ws
Reshma
How to dump a database in postgresql
sudo -i -u postgres

psql
dump postgresql sql
Reshma
How to connect to PostgreSQL database and dis
import psycopg2

conn = psycopg2.connect(host="localhost"
python psycopg2 postgresql
kishore_kumar
Connect to PostgreSQL in c# applications usin
using System.Text;
using System.Threading.Tasks;
using IronPython.Hosting;
c# csharp postgresql npgsql
harika
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
Reshma
How to delete SEQUENCE in postgresql
drop sequence sequence_name;
sequence postgresql mysql
Reshma
How to copy a table from one database to anot
pg_dump -U user1 db_name_old_db | psql -
database postgresql copy table mysql
Reshma