Create Database/Tables -PostgreSQL
I am trying to create pgsql database/tables for freeRADIUS. I notice that PostgreSQL has a schema for freeRADUS. Is there any procedure to create the DB/Tables from this schema or I have to type all the lines to create table manually?
On Sat, May 23, 2009 at 03:05:39PM -0600, Just E. Mail wrote:
I am trying to create pgsql database/tables for freeRADIUS. I notice that PostgreSQL has a schema for freeRADUS. Is there any procedure to create the DB/Tables from this schema or I have to type all the lines to create table manually?
The shell commands I did to create a DB user, an empty DB and the tables for FreeRADIUS: $ createuser -P raduser $ createdb -O raduser raddb $ sed "s/'now'/now()/" /etc/raddb/sql/postgresql/schema.sql | psql -h localhost -d raddb -U raduser -W The "sed" command was necessary because the included schema.sql erroneously contained "'now'" (note the single quotes) i.s.o. "now()", which does not work correctly. This was with FreeRADIUS 2.0.5 so this bug might have been solved in the meantime. -- -- Jos Vos <jos@xos.nl> -- X/OS Experts in Open Systems BV | Phone: +31 20 6938364 -- Amsterdam, The Netherlands | Fax: +31 20 6948204
I am trying to create pgsql database/tables for freeRADIUS. I notice that PostgreSQL has a schema for freeRADUS. Is there any procedure to create the DB/Tables from this schema or I have to type all the lines to create table manually?
Of course not by hand. Yes, there are procedures for creating databases, users, assigning users to databases, giving them permissions etc., even reading input from a file (there are actually several options for doing that). Perhaps you should first find out what these things are for: http://www.postgresql.org/docs/manuals/ Ivan Kalik Kalik Informatika ISP
Ivan Kalik wrote:
Of course not by hand. Yes, there are procedures for creating databases, users, assigning users to databases, giving them permissions etc., even reading input from a file (there are actually several options for doing that). Perhaps you should first find out what these things are for:
http://www.postgresql.org/docs/manuals/
Ivan Kalik Kalik Informatika ISP
Ivan: I have gone through all 2,000+ pages of the manual you mentioned. Somehow I missed answer to my question. Will you be kind enough to let me know the chapter where it discusses creating data using a text file? Thanks. Jennifer
Just E. Mail wrote:
I have gone through all 2,000+ pages of the manual you mentioned. Somehow I missed answer to my question. Will you be kind enough to let me know the chapter where it discusses creating data using a text file?
Google: postgresql command-line client http://www.commandprompt.com/ppbook/c4890.htm Read it. The answer you need is there. The schema file can be used as an input file to the client. It's like a shell for SQL. And with a shell... you can read commands from a file. All of the SQL databases have this capability. And with FreeRADIUS, radclient has a similar capability, as does radmin. If you got as far as being able to type in the queries by hand, you *must* have been using the postgres command-line tool. In which case... you could even pipe the schema file into the CLI, *just like* you had typed it in. This is really Unix 101: moving text between files and programs. Alan DeKok.
Ivan Kalik wrote:
Of course not by hand. Yes, there are procedures for creating databases, users, assigning users to databases, giving them permissions etc., even reading input from a file (there are actually several options for doing that). Perhaps you should first find out what these things are for:
http://www.postgresql.org/docs/manuals/
Ivan Kalik Kalik Informatika ISP
Ivan:
I have gone through all 2,000+ pages of the manual you mentioned. Somehow I missed answer to my question. Will you be kind enough to let me know the chapter where it discusses creating data using a text file?
psql. You have a \ command option, - (--) comand option, or even good old < way to do it. I haven't seen a guide on posgresql that doesn't describe at least one of these ways of importing command from a file. Ivan Kalik Kalik Informatika ISP
participants (4)
-
Alan DeKok -
Ivan Kalik -
Jos Vos -
Just E. Mail