Differences between mysql and oracle

Source: Internet
Author: User
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'

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.