sql

Status
Not open for further replies.

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
what is wrong with
CREATE TABLE Person
(
LastName varchar,
FirstName varchar,
Address varchar,
Age int
)
?

I took it directly form http://www.w3schools.com/sql/sql_create.asp but it says:

SQL-fråga:
CREATE TABLE Person(LastName varchar,
FirstName varchar,
Address varchar,
Age int
)
MySQL sa:
#1064 - 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 '
FirstName varchar,
Address varchar,
Age int
)' at line 3

how can w3schools have wrong? This happens to everything I type in my phpmyadmin
 

phpasks

New Member
Messages
145
Reaction score
0
Points
0
You can used this way

CREATE TABLE `test` (
`id` int(11) NOT NULL auto_increment,
`en1` enum('Y','N') default NULL,
`field2` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 

freecrm

New Member
Messages
629
Reaction score
0
Points
0
As far as I'm aware, for variable and integer characters, you cannot define the field without a character length.

i.e.

CREATE TABLE Person
(
LastName varchar (50),
FirstName varchar (50),
Address varchar (200),
Age int (2)
)


You don't have to propose lengths for longtext or dates for instance.

I think you'll find that in the W3schools document, it does give this example.

http://www.w3schools.com/php/php_mysql_create.asp
 
Status
Not open for further replies.
Top