psql -U postgres
CREATE DATABASE my_test_db
\l
\c my_test_db
\d
\c database_name;
ALTER TABLE table_name ADD COLUMN IF NOT EXISTS column_name INTEGER;
ALTER TABLE table_name DROP COLUMN IF EXISTS column_name;
psql -U postgres -d northwind
psql -U postgres
CREATE DATABASE my_test_db
\l
\c my_test_db
\d
\c database_name;
ALTER TABLE table_name ADD COLUMN IF NOT EXISTS column_name INTEGER;
ALTER TABLE table_name DROP COLUMN IF EXISTS column_name;
psql -U postgres -d northwind
psql -U postgres -c 'show hba_file'
brew services restart postgresql@16
Get comma separated data
You can use the
array()
andarray_to_string()
functions together with your query.With SELECT array( SELECT id FROM table ); you will get a result like: {1,2,3,4,5,6}
Then, if you wish to remove the {} signs, you can just use the
array_to_string()
function and use comma as separator, so:SELECT array_to_string( array( SELECT id FROM table ), ',' ) will get a result like: 1,2,3,4,5,6