Creating a Table
#!\usr\bin\perl
use warnings;
use strict;
use DBI;
my ($dbh, $sth);
$dbh=DBI->connect('dbi:mysql:test','root','password') || die "Error opening database: $DBI::errstr\n";
$sth=$dbh->prepare("CREATE TABLE checkin (id INTEGER AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(32) NOT NULL,
lastname VARCHAR(32) NOT NULL,
destination VARCHAR(32) NOT NULL)");
$sth->execute(); # execute the statement
$sth->finish(); # finish the execution
print "All done\n";
$dbh->disconnect || die "Failed to disconnect\n";
Related examples in the same category