Comments - noinstall package for MariaDB(such as XAMPP, formerly known as LAMP)

11 years, 5 months ago Elena Stepanova

You have 4 different problems in your query.

The one that you are stuck at now is that you surrounded column names with single quote marks. You need to either remove them at all, or to replace them with back ticks:

create table if not exists addresslist( 
`id` int not null auto_increment, 
`firstname` varchar not null, 
`lastname` varchar not null, 
`city` varchar not null, 
`state` char(2), 
`country` text default 'usa', 
`zip` text(10) not null 
primary key (id) );

Then you will start getting another syntax error:

near 'not null, 
`lastname` varchar not null, 
`city` varchar not null, 
`state` char('

It will be happening because VARCHAR requires a length parameter, so you will need to replace all varchar with something like varchar(64), or whatever length you need:

create table if not exists addresslist( 
`id` int not null auto_increment, 
`firstname` varchar(64) not null, 
`lastname` varchar(64) not null, 
`city` varchar(64) not null, 
`state` char(2), 
`country` text default 'usa', 
`zip` text(10) not null 
primary key (id) );

Then there will be error

BLOB/TEXT column 'country' can't have a default value

which is rather self-explanatory: you need to remove the default value from the text column:

create table if not exists addresslist( 
`id` int not null auto_increment, 
`firstname` varchar(64) not null, 
`lastname` varchar(64) not null, 
`city` varchar(64) not null, 
`state` char(2), 
`country` text, 
`zip` text(10) not null 
primary key (id) );

Now you will have a syntax error again:

near '(id) )'

which is caused by a missing comma before primary key definition. Fix it, and your query will work:

> create table if not exists addresslist( 
    -> `id` int not null auto_increment, 
    -> `firstname` varchar(64) not null, 
    -> `lastname` varchar(64) not null, 
    -> `city` varchar(64) not null, 
    -> `state` char(2), 
    -> `country` text, 
    -> `zip` text(10) not null, 
    -> primary key (id) );
Query OK, 0 rows affected (0.03 sec)

P.S. Please next time try to choose an appropriate category or topic for your question, this one has nothing to do with noinstall packages.

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.