How to exclude PL/pgSQL functions in export?

后端 未结 3 990
感情败类
感情败类 2021-01-16 13:00

I use following command to dump some structures from server\' database to be able to create sample of data on my local hard drive.

pg_dump -h myserver.com -U         


        
3条回答
  •  佛祖请我去吃肉
    2021-01-16 14:03

    I need to exclude some schemas

    pg_dump has a switch to exclude schemas:

    pg_dump -N schema ...
    

    I quote the manual about pg_dump:

    -N schema
    --exclude-schema=schema

    Do not dump any schemas matching the schema pattern. The pattern is interpreted according to the same rules as for -n. -N can be given more than once to exclude schemas matching any of several patterns.
    ...


    With PostgreSQL 9.1 or later you have new options to move extensions into a separate schema - even pre-installed old-style modules. You can register old object with your (new-style) extension and then use the new tools. With fulltext and similarity you probably mean fuzzystrmatch and tsearch2. Example:

    Register existing old-style objects for the extension fuzzystrmatch:

    CREATE EXTENSION fuzzystrmatch SCHEMA public FROM unpackaged;
    

    Drop the extension:

    DROP EXTENSION fuzzystrmatch;
    

    Install it to another schema:

    CREATE EXTENSION fuzzystrmatch SCHEMA my_schema;
    

    Of course, you cannot drop the extension, if objects from it are in use.
    Also, if you install to another schema, you need to schema-qualify its functions in use or add the schema to the search_path.

提交回复
热议问题