Pg module question

I'm trying to create a table in a PostgreSQL database and I can't figure out the syntax.

The PostgreSQL site tells me
CREATE TABLE TEST (NAM VARCHAR (40), ADD VARCHAR (40), PHO VARCHAR(40));

This doesn't work ('Internal server error').

I tried $db->CREATE TABLE .....   Same error message.

I have the documentation for the module, from CPAN, but it doesn't talk about the syntax for this (or SELECT, or alot of things).

How do you create a table?

the code:

#!usr/bin/perl -w
use strict;
use DBI;
my $db = DBI->connect("dbi:pg:dbname=me;host=sql");
$db->CREATE TABLE TEST (NAM VARCHAR (40), ADD VARCHAR (40), PHO VARCHAR(40));
$db->DROP TABLE TEST;
$db->disconnect;


ardasheksAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
bigbedConnect With a Mentor Commented:
your create table and drop table statements should be something like:
$db->execute('CREATE TABLE TEST (NAM VARCHAR (40), ADD VARCHAR (40), PHO VARCHAR(40)');
$db->execute('DROP TABLE TEST');

Take a look at:
http://www.perl.com/pub/1999/10/DBI.html

Does this help?
0
 
adam923Commented:
perl functions don't have spaces so you're missing something here, but i don't know much about DBI so check out http://www.perl.com/pub/1999/10/DBI.html
0
All Courses

From novice to tech pro — start learning today.