Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create autoincrement key in Java DB using NetBeans IDE

I'm coming from MySQL world, please help.

Is it possible to create autoincrement key from NetBeans IDE in JavaDB?

Do you use some more advanced db clients, which?

Thanks.

like image 953
umpirsky Avatar asked Jul 22 '10 11:07

umpirsky


People also ask

How do you create an autoincrement?

The MS SQL Server uses the IDENTITY keyword to perform an auto-increment feature. In the example above, the starting value for IDENTITY is 1, and it will increment by 1 for each new record. Tip: To specify that the "Personid" column should start at value 10 and increment by 5, change it to IDENTITY(10,5) .

Can you create an auto increment on a unique key?

Auto Increment is a field used to generate a unique number for every new record added into a table. This is generally used for the primary key column as it becomes easy for the developers to automatically generate a unique number for every new record.

How does MySQL Autoincrement work?

Auto Increment is a function that operates on numeric data types. It automatically generates sequential numeric values every time that a record is inserted into a table for a field defined as auto increment.

Is auto increment always primary key?

The above statement is true. Primary key should always be auto increment.


1 Answers

This may help you:

CREATE TABLE "custinf"  (        "CUST_ID" INT not null primary key         GENERATED ALWAYS AS IDENTITY         (START WITH 1, INCREMENT BY 1),       "FNAME" VARCHAR(50),         "LNAME" VARCHAR(50),    "ADDR" VARCHAR(100),    "SUBURB" VARCHAR(20),    "PCODE" INTEGER,      "PHONE" INTEGER,    "MOB" INTEGER,        "EMAIL" VARCHAR(100),    "COMM" VARCHAR(450)     ); 

That's how i got mine to work... to ages to get the frigging thing to actually understand me but that's the nature of code :D

BTW!- There is a way to do it in the ide interface goto the services window, expand your connection, expand your projects name, expand tables, right click indexes and select add index... the rest of the process speaks for itself really...

like image 90
Sam Avatar answered Sep 22 '22 06:09

Sam