sqlite3: creating table with no columns sqlite3: creating table with no columns sqlite sqlite

sqlite3: creating table with no columns


Zero-column tables aren't supported in SQLite. Or in the SQL standard either.


I had this same question because I wanted a table with only the rowid field. While you may not be able to create a table without columns, you can make a table with only a rowid field as the primary key using the following code:

CREATE TABLE tablename (rowid INTEGER PRIMARY KEY) WITHOUT ROWID;


you can create table with only id column instead of creating empty table:

def create_table(DATABESE_NAME):    conn = sqlite3.connect(DATABESE_NAME)    c = conn.cursor()    c.execute(''' CREATE TABLE IF NOT EXISTS rate_table(    id INTEGER PRIMARY KEY AUTOINCREMENT) ''')    conn.commit()    conn.close()