create table Card
(
Cid int primary key AUTO_INCREMENT  ,
Uid char(20) foreign key (Uid) references users(Uid)
 on update cascade on delete cascade,
registertime timestamp not null default now(),
registermoney float default 5.0,
passwd int not null,
balance float not null,
states enum('男','女')  not null default '男'
) ATUO_INCREMENT = 10000;[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'foreign key (Uid) references users(Uid)
 on update cascade on delete cascade,' at line 4
顺便请问下怎么约束passwd的长度,用触发器吗?

解决方案 »

  1.   

    语法 不对,可以参考一下MYSQL官方免费手册中的语法。
    Uid char(20) references users(Uid)的换成 varchar(10)
      

  2.   

    谢了。。感觉语句跟SQL SERVER 差太多了
      

  3.   


    create procedure insert_card (users_ID char(20), registe_ money float,  passwd int )
    begin
    insert into card(Uid, registermoney, passwd, balance)
    values(users_ID, registe_ money, passwd, registe_ money);
    end;Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'money float,  passwd int )
    begin
    insert into card(Uid, registermoney, passwd,' at line 1请问下着是哪cuoel
      

  4.   

    create procedure insert_card (users_ID char(20), registe_ money float,  passwd int )
    insert into card(Uid, registermoney, passwd, balance)
    values(users_ID, registe_ money, passwd, registe_ money);