2
CREATE TABLE test(ID_NO INT NOT NULL AUTO_INCREMENT, 
    Account varchar(20)NOT NULL, 
    Day DATE NOT NULL, 
    Customer BIGINT(20) NOT NULL, 
    Clicks INT(10) NOT NULL,
    Impression INT(20) NOT NULL, 
    CTR FLOAT(10) NOT NULL, 
    Avg. CPC FLOAT(10) NOT NULL, 
    Cost FLOAT(10) NOT NULL, 
    Avg. position FLOAT(10) NOT NULL, 
    Converted clicks INT(10) NOT NULL, 
    Conversions INT(10) NOT NULL,
    Conv. rate FLOAT(10) NOT NULL,
    PRIMARY KEY(ID_NO)
);

ERROR 1103 (42000): Incorrect table name 'Avg'

Musa Haidari
  • 2,109
  • 5
  • 30
  • 53
Raghul PR
  • 47
  • 1
  • 2
  • 9
  • how to clear this error? can anybody help me..... – Raghul PR Nov 03 '15 at 06:34
  • 1
    Avg is a reserved word, since it is a name of a function. Enclose it by backticks ``. Also enclose all field names containing periods or spaces by backticks. – Shadow Nov 03 '15 at 06:39
  • 1
    Possible duplicate of [How do I escape reserved words used as column names? MySQL/Create Table](http://stackoverflow.com/questions/2889871/how-do-i-escape-reserved-words-used-as-column-names-mysql-create-table) – diziaq Nov 03 '15 at 07:06

3 Answers3

1

Please try below query :

CREATE TABLE test
(ID_NO INT NOT NULL AUTO_INCREMENT, 
Account varchar(20)NOT NULL, 
Day DATE NOT NULL,
Customer BIGINT(20) NOT NULL,  
Impression INT(20) NOT NULL, 
CTR FLOAT(10) NOT NULL, 
CPC FLOAT(10) NOT NULL, 
Cost FLOAT(10) NOT NULL,  
position FLOAT(10) NOT NULL, 
clicks INT(10) NOT NULL, 
Conversions INT(10) NOT NULL,
rate FLOAT(10) NOT NULL, 
PRIMARY KEY(ID_NO));
Ashish Detroja
  • 1,084
  • 3
  • 10
  • 32
0
mysql> CREATE TABLE test(ID_NO INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
Account varchar(20)NOT NULL, 
Day DATE NOT NULL, 
Customer BIGINT(20) NOT NULL, 
Clicks INT(10) NOT NULL,
Impression INT(20) NOT NULL, 
CTR FLOAT(10) NOT NULL, 
Avg_CPC FLOAT(10) NOT NULL, 
Cost FLOAT(10) NOT NULL, 
Avg_position FLOAT(10) NOT NULL, 
Converted clicks INT(10) NOT NULL, 
Conversions INT(10) NOT NULL,
Conv_rate FLOAT(10) NOT NULL
);                              
Kushal Vora
  • 342
  • 2
  • 16
Kaushik Maheta
  • 1,741
  • 1
  • 18
  • 27
0

There are multiple problems with your query.

  • You cannot use dots in the names (or identifiers as MySQL calls them)
  • You cannot use spaces in identifiers
  • It is better to use underscored names rather, and avoid using the upper case in identifiers, since MySQL is not case sensitive.

The final code comes to be:

CREATE TABLE test(
    id_no INT NOT NULL AUTO_INCREMENT, 
    account varchar(20)NOT NULL, 
    day DATE NOT NULL, 
    customer BIGINT(20) NOT NULL, 
    clicks INT(10) NOT NULL,
    impression INT(20) NOT NULL, 
    ctr FLOAT(10) NOT NULL, 
    avg_cpc FLOAT(10) NOT NULL, # there was a dot in the name
    cost FLOAT(10) NOT NULL, 
    avg_position FLOAT(10) NOT NULL, # there was a dot in the name
    converted_clicks INT(10) NOT NULL, # there was an extra space
    conversions INT(10) NOT NULL,
    conv_rate FLOAT(10) NOT NULL, # there was a dot in the name
    PRIMARY KEY(ID_NO)
);
Musa Haidari
  • 2,109
  • 5
  • 30
  • 53