SQL, Postgres OIDs, What are they and why are they useful?

后端 未结 5 956
一个人的身影
一个人的身影 2020-12-07 10:28

I am looking at some PostgreSQL table creation and I stumbled upon this:

CREATE TABLE (
...
) WITH ( OIDS = FALSE );

I read the documentati

5条回答
  •  孤城傲影
    2020-12-07 10:39

    To remove all OIDs from your database tables, you can use this Linux script:

    First, login as PostgreSQL superuser:

    sudo su postgres
    

    Now run this script, changing YOUR_DATABASE_NAME with you database name:

    for tbl in `psql -qAt -c "select schemaname || '.' || tablename from pg_tables WHERE schemaname <> 'pg_catalog' AND schemaname <> 'information_schema';" YOUR_DATABASE_NAME` ; do  psql -c "alter table $tbl SET WITHOUT OIDS" YOUR_DATABASE_NAME ; done
    

    I used this script to remove all my OIDs, since Npgsql 3.0 doesn't work with this, and it isn't important to PostgreSQL anymore.

提交回复
热议问题