How to copy a table's schema

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
JoseRaul
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 18.02.2007, 21:21

How to copy a table's schema

Post 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!
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
JoseRaul
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 18.02.2007, 21:21

Post 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
JoseRaul
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 18.02.2007, 21:21

Post 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
Post Reply