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'

3
  • how to clear this error? can anybody help me..... Commented Nov 3, 2015 at 6: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. Commented Nov 3, 2015 at 6:39
  • 1
    Possible duplicate of How do I escape reserved words used as column names? MySQL/Create Table Commented Nov 3, 2015 at 7:06

3 Answers 3

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));
Sign up to request clarification or add additional context in comments.

2 Comments

954-778-0978 what is the datatype for entering this number into the mysql?
Please use "varchar".
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)
);

2 Comments

954-778-0978 what is the datatype for entering this number into the mysql?
@Raghulvijay if you mean the numbers that include '-' (dashes), then I think the only ones are varchar or char
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
);                              

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.