perl mysql

#!/usr/bin/perl
  2 use DBI;   #启用DBI接口
  3 use strict;
  4
  5 my $dbh = DBI->connect("DBI:mysql:host=localhost",
  6                              "root", "PWD",{'RaiseError' => 1});
  7 #建库
  8 $dbh -> do("DROP database if exists woodformation");
  9 $dbh -> do("CREATE DATABASE woodformation DEFAULT CHARACTER SET utf8 COLLATE     utf8_unicode_ci");
 #建库并设置字符集
 10 my $dbh = DBI->connect('DBI:mysql:woodformation:localhost',"root","PWD") or die "无法连接数据库: " . DBI->errstr;
 11
 12 #species表
 13 $dbh -> do("drop TABLE if exists species");
 14 $dbh -> do("CREATE TABLE species
 15 (
 16 spe       varchar(50) NOT NULL PRIMARY KEY,
 17 lanspe    varchar(100)
#最后一个语句没有逗号
 18 )ENGINE=MyISAM DEFAULT CHARSET=utf8;
#设置表的字符集

 19 ");


$dbh -> disconnect();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值