--使用数据库
use test;
--删除表
drop mytb;
--创建表
create table mytb(
id int(11) primary key  auto_increment,
tel int()
);
--事务提交
commint;
这个脚本有错误啊,不知道为什么,还有写的不够完善,比如说,如果表mytb不存在就会出错,怎么才能判断一下,如果mytb表存在,那么就不执行删除命令,直接提交呢

解决方案 »

  1.   

    create table mytb(
    id int(11) primary key  auto_increment,
    tel int()
    );int类型不需要指明精度,只要声明就行了,当然,也可以指明,但tel int()中没有指明,所以报错了。应该这样写:
    create table mytb(
    id int primary key  auto_increment,
    tel int
    );
      

  2.   

    判断是否有mytb可以这么写!
    DROP TABLE IF EXISTS `test`.`mytb`;
      

  3.   

    drop mytb;改称drop table mytb;
      

  4.   

    DROP TABLE IF EXISTS tablename;
    CREATE TABLE tablename(
      iNo int(11) NOT NULL auto_increment,
      dPK int(11) NOT NULL default '0',
      str1 varchar(8) NOT NULL default 'cn',
      name varchar(200) default NULL,
      PRIMARY KEY  (iNo)
    )ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;