Welcome to the Linux community forum and interact with 2 million technical staff. the difference between mysql and oracle databases in implementing auto-increment columns: mysql can implement auto-increment columns, As long as auto_increment is set during table creation, and oracle cannot set auto-increment columns during table creation, you must use the sequence to implement the auto-incrementing column function and establish the sequence
Welcome to the Linux community forum and interact with 2 million technical staff> enter 1. the difference between mysql and oracle databases in implementing auto-increment columns: mysql can implement auto-increment columns, As long as auto_increment is set during table creation, and oracle cannot set auto-increment columns during table creation, you must use the sequence to implement the auto-incrementing column function and establish the sequence
Welcome to the Linux community forum and interact with 2 million technicians>
1. Differences between mysql and oracle databases for auto-increment columns:
Mysql can implement auto-increment columns. You only need to set auto_increment when creating a table, but oracle cannot set auto-increment columns when creating a table,
You must use the sequence to implement the auto-incrementing column function. The statement for creating the sequence is as follows (assuming the sequence is named ts_sequence ):
Create sequence ts_sequence
Increment by 1 -- add several
Start with 1 -- count from 1
NOMAXVALUE -- do not set the maximum value
NOCYCLE -- always accumulate without repeating
CACHE 10;
After sequence is defined, you can use ts_sequence.nextval and ts_sequence.currval In the insert statement,
Ts_sequence.currval returns the current sequence value, but it must be used after the first ts_sequence.nextval initialization.
Ts_sequence.currval.
2. Differences between mysql and oracle Database indexes:
In the entire database, mysql indexes can have the same name, that is, mysql indexes are table-level, but Oracle indexes cannot have the same name, that is, Oracle indexes are database-level;
Mysql indexes start from 0 and oracle indexes start from 1.
The two indexes are the same:
Create index indexName on tableName (columnName );
Delete Index
Mysql:
Alter table tableName drop index indexName
Oracle:
Drop index indexName
Query the index of a table
Mysql:
Show index from tableName
Oracle:
Select index_name, table_name, column_name from user_ind_columns where table_name = 'tablename'