Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to create a table in the data base but the error

what's wrong with my code

code

CREATE TABLE ad_banners (
  aid           int(11)  DEFAULT '0' NOT NULL auto_increment,
  name          tinytext, 
  description   tinytext, 
  size          varchar(7), 
  file_type     varchar(4),
  status        varchar(1), 
  date          datetime, 
  url           tinytext, 
  PRIMARY KEY (aid)
);


CREATE TABLE ad_errors (
  date            datetime,
  cid             int(11),
  aid             int(11),
  pid             int(11),
  http_referer    tinytext,
  remote_addr     varchar(15),
  http_user_agent tinytext,
  error           text,
  request_uri     tinytext
);


CREATE TABLE ad_groups (
  gid          char(16)  DEFAULT '' NOT NULL,
  aid          int(11)   DEFAULT '0' NOT NULL,
  date         int(11),
  nweight_lb   double(6,4),
  nweight_ub   double(6,4),
  KEY gid (gid)
);


CREATE TABLE ad_partners (
  pid           int(11)  DEFAULT '0' NOT NULL auto_increment,
  status        char(16), 
  gid           char(16), 
  expire_date   int(11)  DEFAULT '0' NOT NULL,
  PRIMARY KEY (pid)
);


CREATE TABLE ad_summary (
  pid        int(11)  DEFAULT '0' NOT NULL,
  aid        int(11)  DEFAULT '0' NOT NULL,
  date       int(11)  DEFAULT '0' NOT NULL,
  date_year  int(6)   DEFAULT '0' NOT NULL,
  date_month tinyint(4)  DEFAULT '0' NOT NULL,
  date_mday  tinyint(4)  DEFAULT '0' NOT NULL,
  date_wday  tinyint(4)  DEFAULT '0' NOT NULL,
  date_hour  tinyint(4)  DEFAULT '0' NOT NULL,
  hits       int(11), 
  clicks     int(11), 
  mid        tinyint(4),  
  KEY pid (pid),
  KEY aid (aid),
  KEY date (date)
);


CREATE TABLE clients_1 (
  cid             int(11)     DEFAULT '0' NOT NULL auto_increment,
  remote_addr     varchar(15) DEFAULT '' NOT NULL,
  http_user_agent tinytext,
  mid             tinyint(4)  DEFAULT '0' NOT NULL,
  PRIMARY KEY (cid)
);


CREATE TABLE hits_1 (
  cid                 int(11)  DEFAULT '0' NOT NULL,
  sid                 int(11)  DEFAULT '0' NOT NULL,
  pid                 int(11)  DEFAULT '0' NOT NULL,
  aid                 int(11)  DEFAULT '0' NOT NULL,
  date                int(11), 
  remote_addr         varchar(15)   DEFAULT '' NOT NULL,
  http_referer_host   tinytext, 
  http_referer_query  tinytext, 
  http_user_agent     tinytext, 
  mid                 tinyint(4)  DEFAULT '0' NOT NULL
);


CREATE TABLE tracking_sites (
  sid   int(11) DEFAULT '0' NOT NULL auto_increment,
  name  tinytext,
  PRIMARY KEY (sid)
);


CREATE TABLE tracking_summary (
  sid        int(11)  DEFAULT '0' NOT NULL,
  date       int(11)  DEFAULT '0' NOT NULL,
  date_year  int(6)  DEFAULT '0' NOT NULL,
  date_month tinyint(4) DEFAULT '0' NOT NULL,
  date_mday  tinyint(4) DEFAULT '0' NOT NULL,
  date_wday  tinyint(4) DEFAULT '0' NOT NULL,
  date_hour  tinyint(4) DEFAULT '0' NOT NULL,
  hits       int(11),
  clicks     int(11),
  mid        tinyint(4) DEFAULT '0',
  KEY sid (sid),
  KEY date (date)
);


Error
#1067 - Invalid default value for 'aid'
:confused::confused:


CREATE TABLE ad_banners(
aid int( 11 ) DEFAULT '0' NOT NULL AUTO_INCREMENT ,
name tinytext,
description tinytext,
size varchar( 7 ) ,
file_type varchar( 4 ) ,
STATUS varchar( 1 ) ,
date datetime,
url tinytext,
PRIMARY KEY ( aid )
);

#1067 - Invalid default value for 'aid'

Can you help me
Posted
Updated 20-Feb-10 22:45pm
v3

I suggest buying a basic book on SQL. Anything in quotes is a string. Your int type should have a default value of 0, not '0'
 
Share this answer
 
I've changed '0 ' to 0 but still the same error

Can you provide more detail I am still learning

:confused::confused: :doh:
 
Share this answer
 
int doesnt allow size.

so you shouldnt be specifying int(11).

SQL
CREATE TABLE ad_banners(
aid int DEFAULT '0' NOT NULL ...


This is what you specify...
;P
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900