Sequence Introduction
A sequence is a database object that generates an automatically incremented list of numeric values according to the rules defined in the sequence specification. The sequence of numeric values is generated in an ascending or descending order at a defined increment interval, and the numbers generated by a sequence can be used by applications, for example, to identify the rows and columns of a table
Sequences are not associated with tables; they are used by applications, which can use CURRVAL in a SQL statement to get the current value generated by a sequence and
NEXTVAL to generate the next value in the defined sequence.
EX- suppose we want to change Row based table into column based table with a primary key as a sequence but in row based table there is no primary key.
Creating Sequence
A sequence is a database object that generates an automatically incremented list of numeric values according to the rules defined in the sequence specification. The sequence of numeric values is generated in an ascending or descending order at a defined increment interval, and the numbers generated by a sequence can be used by applications, for example, to identify the rows and columns of a table
Sequences are not associated with tables; they are used by applications, which can use CURRVAL in a SQL statement to get the current value generated by a sequence and
NEXTVAL to generate the next value in the defined sequence.
EX- suppose we want to change Row based table into column based table with a primary key as a sequence but in row based table there is no primary key.
Creating Sequence
- Import the table into Hana system go to File-->Import
- Fill all the details which is required
- Now on next screen put which type of table you want to create Row Based or Column Based
- Now it will show the output of table and click on Finish it will create Row based table into your schema Table folder
- Now we will create a sequence which will convert row based table into column based with a primary key
below code will create one sequence which will increment
- Now create a column based table so we can convert out Row based Table to Column Based Table using Sequence
Right click on your schema-->New Table create table with 2 column SPID & SP_NAME
- Run the below code so it can generate one column as a primary key and always incremented by 1
- Run the below code and see the output
For more information and tutorials mail me sandeepcts1989@gmail.com
below code will create one sequence which will increment
Right click on your schema-->New Table create table with 2 column SPID & SP_NAME
For more information and tutorials mail me sandeepcts1989@gmail.com
No comments:
Post a Comment