0

I want the ID for the client to be on 4 positions like "0007" on apache derby but the following request doesn't work:

create table client(id int (5)  not null AUTO_INCREMENT primary key, fname varchar(20) not null, lname varchar(20) not null,phnum int(10) not null, email varchar(60) not null ) ; 

it throws this exception:

[Exception, Error code 30 000, SQLState 42X01] Erreur de syntaxe : Encountered "(" at line 1, column 28.

how can I make it happen ?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Ammari Amira
  • 89
  • 1
  • 1
  • 10

1 Answers1

0
  1. The Derby int has no width. It is soley an integer.

  2. You may use formatting, to use the id as a 4 digit wide string.

  3. Probably you will use your Derby data later in Java thrua a ORM. It is not recomended to use business data as an object id. Let the id an auto-incrementet value to identify your object. You may add another field (like code) to have the client code stored (char(4) with a unique index to avoid duplicates).

(4. Only preview 10.000 clients, that seems a quiet low limit)

PeterMmm
  • 24,152
  • 13
  • 73
  • 111