Search code examples
mysqlsqlsqliteddlcreate-table

How to set number as row name in mysql


In SQLite, I want to create a table with row name as numbers like 1 , 2, 3 ,4

CREATE TABLE NUMBERTABLE ( 1 INTEGER , 2 INTEGER , 3 INTEGER ) ;

but it doesnt work .

I searched over the Internet but I couldn't find the solution. Can anyone show me how to do this ?


Solution

  • Those are column names, not row names. MySQL allows you to use backticks to escape column names, as such:

    CREATE TABLE numbertable (`1` INTEGER, `2` INTEGER, `3` INTEGER);
    

    But this is more often than not a recipe for bugs later on. It would be much easier to just use valid column names. E.g.:

    CREATE TABLE numbertable (col1 INTEGER, col2 INTEGER, col3 INTEGER);