tng-pg-snippets.md#

This is from the Udemy course

Restore#

E:\PostgreSQL\12\bin\pg_restore.exe --host "localhost" --port "5432" --username "postgres" --no-password --dbname "dvdrental" --verbose "f:\\Downloads\\programs\\dvdrental_6.tar"
E:\PostgreSQL\12\bin\pg_restore.exe --host "localhost" --port "5432" --username "postgres" --no-password --dbname "dvdrental" --verbose "f:\\Downloads\\programs\\dvdrental_6.tar"
pg_restore: connecting to database for restore
pg_restore: creating TYPE "public.mpaa_rating"
pg_restore: creating DOMAIN "public.year"
pg_restore: creating FUNCTION "public._group_concat(text, text)"
pg_restore: creating FUNCTION "public.film_in_stock(integer, integer)"
pg_restore: creating FUNCTION "public.film_not_in_stock(integer, integer)"
pg_restore: creating FUNCTION "public.get_customer_balance(integer, timestamp without time zone)"
pg_restore: creating FUNCTION "public.inventory_held_by_customer(integer)"
pg_restore: creating FUNCTION "public.inventory_in_stock(integer)"
pg_restore: creating FUNCTION "public.last_day(timestamp without time zone)"
pg_restore: creating FUNCTION "public.last_updated()"
pg_restore: creating SEQUENCE "public.customer_customer_id_seq"
pg_restore: creating TABLE "public.customer"
pg_restore: creating FUNCTION "public.rewards_report(integer, numeric)"
pg_restore: creating AGGREGATE "public.group_concat(text)"
pg_restore: creating SEQUENCE "public.actor_actor_id_seq"
pg_restore: creating TABLE "public.actor"
pg_restore: creating SEQUENCE "public.category_category_id_seq"
pg_restore: creating TABLE "public.category"
pg_restore: creating SEQUENCE "public.film_film_id_seq"
pg_restore: creating TABLE "public.film"
pg_restore: creating TABLE "public.film_actor"
pg_restore: creating TABLE "public.film_category"
pg_restore: creating VIEW "public.actor_info"
pg_restore: creating SEQUENCE "public.address_address_id_seq"
pg_restore: creating TABLE "public.address"
pg_restore: creating SEQUENCE "public.city_city_id_seq"
pg_restore: creating TABLE "public.city"
pg_restore: creating SEQUENCE "public.country_country_id_seq"
pg_restore: creating TABLE "public.country"
pg_restore: creating VIEW "public.customer_list"
pg_restore: creating VIEW "public.film_list"
pg_restore: creating SEQUENCE "public.inventory_inventory_id_seq"
pg_restore: creating TABLE "public.inventory"
pg_restore: creating SEQUENCE "public.language_language_id_seq"
pg_restore: creating TABLE "public.language"
pg_restore: creating VIEW "public.nicer_but_slower_film_list"
pg_restore: creating SEQUENCE "public.payment_payment_id_seq"
pg_restore: creating TABLE "public.payment"
pg_restore: creating SEQUENCE "public.rental_rental_id_seq"
pg_restore: creating TABLE "public.rental"
pg_restore: creating VIEW "public.sales_by_film_category"
pg_restore: creating SEQUENCE "public.staff_staff_id_seq"
pg_restore: creating TABLE "public.staff"
pg_restore: creating SEQUENCE "public.store_store_id_seq"
pg_restore: creating TABLE "public.store"
pg_restore: creating VIEW "public.sales_by_store"
pg_restore: creating VIEW "public.staff_list"
pg_restore: processing data for table "public.actor"
pg_restore: processing data for table "public.address"
pg_restore: processing data for table "public.category"
pg_restore: processing data for table "public.city"
pg_restore: processing data for table "public.country"
pg_restore: processing data for table "public.customer"
pg_restore: processing data for table "public.film"
pg_restore: processing data for table "public.film_actor"
pg_restore: processing data for table "public.film_category"
pg_restore: processing data for table "public.inventory"
pg_restore: processing data for table "public.language"
pg_restore: processing data for table "public.payment"
pg_restore: processing data for table "public.rental"
pg_restore: processing data for table "public.staff"
pg_restore: processing data for table "public.store"
pg_restore: executing SEQUENCE SET actor_actor_id_seq
pg_restore: executing SEQUENCE SET address_address_id_seq
pg_restore: executing SEQUENCE SET category_category_id_seq
pg_restore: executing SEQUENCE SET city_city_id_seq
pg_restore: executing SEQUENCE SET country_country_id_seq
pg_restore: executing SEQUENCE SET customer_customer_id_seq
pg_restore: executing SEQUENCE SET film_film_id_seq
pg_restore: executing SEQUENCE SET inventory_inventory_id_seq
pg_restore: executing SEQUENCE SET language_language_id_seq
pg_restore: executing SEQUENCE SET payment_payment_id_seq
pg_restore: executing SEQUENCE SET rental_rental_id_seq
pg_restore: executing SEQUENCE SET staff_staff_id_seq
pg_restore: executing SEQUENCE SET store_store_id_seq
pg_restore: creating CONSTRAINT "public.actor actor_pkey"
pg_restore: creating CONSTRAINT "public.address address_pkey"
pg_restore: creating CONSTRAINT "public.category category_pkey"
pg_restore: creating CONSTRAINT "public.city city_pkey"
pg_restore: creating CONSTRAINT "public.country country_pkey"
pg_restore: creating CONSTRAINT "public.customer customer_pkey"
pg_restore: creating CONSTRAINT "public.film_actor film_actor_pkey"
pg_restore: creating CONSTRAINT "public.film_category film_category_pkey"
pg_restore: creating CONSTRAINT "public.film film_pkey"
pg_restore: creating CONSTRAINT "public.inventory inventory_pkey"
pg_restore: creating CONSTRAINT "public.language language_pkey"
pg_restore: creating CONSTRAINT "public.payment payment_pkey"
pg_restore: creating CONSTRAINT "public.rental rental_pkey"
pg_restore: creating CONSTRAINT "public.staff staff_pkey"
pg_restore: creating CONSTRAINT "public.store store_pkey"
pg_restore: creating INDEX "public.film_fulltext_idx"
pg_restore: creating INDEX "public.idx_actor_last_name"
pg_restore: creating INDEX "public.idx_fk_address_id"
pg_restore: creating INDEX "public.idx_fk_city_id"
pg_restore: creating INDEX "public.idx_fk_country_id"
pg_restore: creating INDEX "public.idx_fk_customer_id"
pg_restore: creating INDEX "public.idx_fk_film_id"
pg_restore: creating INDEX "public.idx_fk_inventory_id"
pg_restore: creating INDEX "public.idx_fk_language_id"
pg_restore: creating INDEX "public.idx_fk_rental_id"
pg_restore: creating INDEX "public.idx_fk_staff_id"
pg_restore: creating INDEX "public.idx_fk_store_id"
pg_restore: creating INDEX "public.idx_last_name"
pg_restore: creating INDEX "public.idx_store_id_film_id"
pg_restore: creating INDEX "public.idx_title"
pg_restore: creating INDEX "public.idx_unq_manager_staff_id"
pg_restore: creating INDEX "public.idx_unq_rental_rental_date_inventory_id_customer_id"
pg_restore: creating TRIGGER "public.film film_fulltext_trigger"
pg_restore: creating TRIGGER "public.actor last_updated"
pg_restore: creating TRIGGER "public.address last_updated"
pg_restore: creating TRIGGER "public.category last_updated"
pg_restore: creating TRIGGER "public.city last_updated"
pg_restore: creating TRIGGER "public.country last_updated"
pg_restore: creating TRIGGER "public.customer last_updated"
pg_restore: creating TRIGGER "public.film last_updated"
pg_restore: creating TRIGGER "public.film_actor last_updated"
pg_restore: creating TRIGGER "public.film_category last_updated"
pg_restore: creating TRIGGER "public.inventory last_updated"
pg_restore: creating TRIGGER "public.language last_updated"
pg_restore: creating TRIGGER "public.rental last_updated"
pg_restore: creating TRIGGER "public.staff last_updated"
pg_restore: creating TRIGGER "public.store last_updated"
pg_restore: creating FK CONSTRAINT "public.customer customer_address_id_fkey"
pg_restore: creating FK CONSTRAINT "public.film_actor film_actor_actor_id_fkey"
pg_restore: creating FK CONSTRAINT "public.film_actor film_actor_film_id_fkey"
pg_restore: creating FK CONSTRAINT "public.film_category film_category_category_id_fkey"
pg_restore: creating FK CONSTRAINT "public.film_category film_category_film_id_fkey"
pg_restore: creating FK CONSTRAINT "public.film film_language_id_fkey"
pg_restore: creating FK CONSTRAINT "public.address fk_address_city"
pg_restore: creating FK CONSTRAINT "public.city fk_city"
pg_restore: creating FK CONSTRAINT "public.inventory inventory_film_id_fkey"
pg_restore: creating FK CONSTRAINT "public.payment payment_customer_id_fkey"
pg_restore: creating FK CONSTRAINT "public.payment payment_rental_id_fkey"
pg_restore: creating FK CONSTRAINT "public.payment payment_staff_id_fkey"
pg_restore: creating FK CONSTRAINT "public.rental rental_customer_id_fkey"
pg_restore: creating FK CONSTRAINT "public.rental rental_inventory_id_fkey"
pg_restore: creating FK CONSTRAINT "public.rental rental_staff_id_key"
pg_restore: creating FK CONSTRAINT "public.staff staff_address_id_fkey"
pg_restore: creating FK CONSTRAINT "public.store store_address_id_fkey"
pg_restore: creating FK CONSTRAINT "public.store store_manager_staff_id_fkey"

List Tables in DB#

SELECT table_name 
FROM information_schema.tables 
WHERE table_schema='public' AND table_type='BASE TABLE'

List Columns in Table#

SELECT
    COLUMN_NAME
FROM
    information_schema.COLUMNS
WHERE
    TABLE_NAME = 'film';