Hi,

> CREATE TABLE actor (
>  actor_id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT,
>  first_name VARCHAR(45) NOT NULL,
>  last_name VARCHAR(45) NOT NULL,
>  last_update TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
>  PRIMARY KEY  (actor_id),
>  KEY idx_actor_last_name (last_name)
> );

This statement works when using the MySQL compatibility mode. The
documentation is not very clear:
http://h2database.com/html/features.html#compatibility "MySQL":
Creating indexes in the CREATE TABLE statement is allowed.

I will add:

Creating indexes in the CREATE TABLE statement is allowed using
INDEX(..) or KEY(..). Example: create table test(id int primary key,
name varchar(255), key idx_name(name));

The problem is that KEY and INDEX could be used as column names in
other databases. That's why it's not supported in the default mode.

Of course for better compatibility it would be better to change your
application to use the more common CREATE INDEX syntax (as a separate
statement).

Regards,
Thomas

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to