As other has mentioned: Use the information_schema.tables:

SELECT CONCAT('ALTER TABLE "',table_schema,'"."',table_name,'" RENAME TO "IGN_bdTopo_',table_name,'_V1";') AS SQL FROM information_schema.tables
WHERE table_schema = 'ign'

The result from this select is a list of SQL commands to rename each table in schema "ign" to another name. You can apply the same method to generate other "ALTER" commands. Google "postgres alter table"

By the way - It's a bad habit to have mixed-case table identifiers (Just my 2 cents)


Med venlig hilsen / Best regards

Bo Victor Thomsen

Den 27-02-2023 kl. 11:49 skrev celati Laurent:
Good morning,
I am new to Postgresql. I have 50 tables into a "ign" schema (schema other than public).
I would like for each of these 50 tables:

- Add a prefix to the name of the table: "IGN_bdTopo_"
- Add a suffix to the table name: "_V1"
- create a new "date" column of date type. And populate this field with the value: 06/15/2021 - create a new "source" column of type varchar (length 50). And populate this field with the value: 'ign'. - move all the elements of these 50 tables (including all). from the "ign" schema to the "ign_v2" schema. Whether data, constraints, indexes.

If someone could  help me? Thank you so much.

_______________________________________________
postgis-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/postgis-users
_______________________________________________
postgis-users mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/postgis-users

Reply via email to