Click here to Skip to main content
15,914,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My table is orders table. I want order id ORD01 and autoincrement. How can I create? Please, post sample query.
Posted
Updated 23-Apr-12 19:38pm
v2
Comments
Sandeep Mewara 24-Apr-12 1:45am    
Good you 'want' something. Now, this is not a well framed question! We cannot work out what you are trying to do/ask from the post. Please elaborate and be specific.
Use the "Improve question" link to edit your question and provide better information.
DeepthiTanguturi 24-Apr-12 1:49am    
My table is orders table. I want to create order id ORD01 like this and autoincrement. How can I create?

who is waiting to give you query??????? and "Post sample query." not even a request.

add auto_increment constraint to your primary key
try the below query to get next id
SQL
SELECT AUTO_INCREMENT FROM information_schema.TABLES
WHERE TABLE_SCHEMA =  'database_name'
AND TABLE_NAME =  'table_name';
 
Share this answer
 
Hi
SQL
CREATE TABLE TABLE_NAME
                (
                 COLUMN1 DATATYPE (OPTIONAL)PRIMARY KEY AUTOINCREMENT NOT NULL,
                 COLUMN2 DATATYPE (OPTIONAL)NULL,
                )


Example:
SQL
CREATE TABLE [ORDERS]
                (
                 [ORDER_ID] INTEGER  PRIMARY KEY AUTOINCREMENT NOT NULL,
                 [ORDER_BY] VARCHAR(50)  NULL,
                 [ORDER_DATE] TIMESTAMP  NULL,
                 [IS_ACTIVE] BOOLEAN  NULL
                )

This is the sample of create a table u can add as many columns as you can .
 
Share this answer
 
Comments
DeepthiTanguturi 24-Apr-12 1:51am    
But i want order id like this ORD01,ORD02,.......

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900