I am not able to create table like/as with constraints and default values from another table that already exists.
I have tried following
$sql = "CREATE TABLE schemas.a AS TABLE schemas.b";
This creates the table but no constraint or default value is copied.
$sql = "CREATE TABLE schemas.a (LIKE schemas.b INCLUDING CONSTRAINTS)";
This creates the table with not null constraint only. Still the primary key constraint and the default value is not being transferred.
Coding used in php
$sql = "CREATE TABLE schemas.a (LIKE schemas.b INCLUDING CONSTRAINTS)";
pg_query($con, $sql); //This is in the PHP
I want to create the table with all the constraints (primary, unique, not null) and default value that are set.
postgresqluser but seems strange that the behavior is related to PHP.CREATE TABLEcommand.