I am running following query throgh phpMyAdmin:
**CREATE TABLE folders (
folder_id SERIAL NOT NULL,
parent_id BIGINT,
folder_name TEXT NOT NULL,
PRIMARY KEY (folder_id),
FOREIGN KEY (parent_id) REFERENCES folders(folder_id) ON DELETE CASCADE
)ENGINE=InnoDB;**
but it is giving the following error:
#1005 - Can't create table 'filesharingnew.folders' (errno: 150)
Any idea where I am wrong?
From MySQL docs, Numeric Type Overview:
SERIAL
is an alias forBIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE
.
You should change parent_id
into BIGINT UNSIGNED
so it matches the referenced column.