Page 1 of 1
How to copy a table's schema
Posted: 27.02.2007, 13:37
by JoseRaul
Hello everybody, i'm new using zeos and need to import from a postgre8 database it's schema, of course from the code, from command line its so easy!
So I would like to ask if anyone knows how to make a copy of a table including its constraints, not its data. I'm using delphi 10.
I've seen the method gettables from TZPostgreSQLDatabaseMetadata and so, but how to get for example the text of a check clause?
Thank you so much!
Posted: 27.02.2007, 13:54
by mdaems
Hi,
Does postgres have something like a 'show create table' syntax as exists for mysql? That could help.
Why don't you use the command line solution in your program?
Mark
Posted: 27.02.2007, 15:27
by JoseRaul
Hello mdaems, in postgres you can do pg_dump -s <databasename> to get a sql script that creates the schema.
The problem is that I have to connect to a remote database, throw the command and get the result somehow. I don't know how to convert the output to a stream or resultset, it seems complicated, on the other hand is the fastest.
I'm thinking in a stored procedure that returns me a tstring with the script..
Thank you for your help
Posted: 01.03.2007, 10:41
by JoseRaul
Hello, using pg_dump works fine on win32 using a pipe to get the output, the problem is that my client is on windows and the remote server is on linux.
I can only think in connecting trough a socket to run the command, I haven't found if zeos can call anything which is not a sql command ¿maybe using a stored procedure?
Any idea is greatly appreciated
Thanks