I want to create a table in mysql:--
create table app_own(app_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
sp_id bigint(20),
title varchar(30),
description varchar(60),
details LONGTEXT(1000),
primary key(app_id ),
FOREIGN KEY (user_id) REFERENCES student(sp_id));
where app_id is the primary key and sp_id is the foreign key reference from student table..
but I am getting error:--
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '(1000)0,primary key(app_id ),FOREIGN KEY (sp_id)
REFERENCE' at line 1
why the error is occuring?
Try to Run This one:-
use db;
CREATE TABLE parent (
id INT UNSIGNED NOT NULL,
PRIMARY KEY (id)
) ;
CREATE TABLE Persons
(
PID int UNSIGNED NOT NULL AUTO_INCREMENT,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Address varchar(255),
City longtext,
PRIMARY KEY (PID),
FOREIGN KEY (PID)
REFERENCES parent(id)
ON DELETE CASCADE
);
LONGTEXT [CHARACTER SET charset_name] [COLLATE collation_name]
A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 − 1) characters. The effective maximum length is less if the value contains multibyte characters. The effective maximum length of LONGTEXT columns also depends on the configured maximum packet size in the client/server protocol and available memory. Each LONGTEXT value is stored using a 4-byte length prefix that indicates the number of bytes in the value.