Entries Published On May, 2023
Generate the “create table” sql statement for an existing table in postgreSQL 3 Ways
In this video I have shown 3 ways to get create table statements for an existing table in postgreSQL. 1. By creating a function. CREATE OR REPLACE FUNCTION generate_create_table_statement(p_table_name varchar) RETURNS text AS $BODY$ DECLARE v_table_ddl text; column_record record; BEGIN FOR column_record IN SELECT b.nspname as schema_name, b.relname as table_name, a.attname as column_name, …
Continue reading