Some SQL commands commonly used by Oracle

Source: Internet
Author: User

View system Current time HH24 24-hour MI is the right minute

Select To_char (sysdate, ' Yyyy-mm-dd HH24:MI:SS ') from dual

HH non-MM case-insensitive date mm system is considered a month

Select To_char (sysdate, ' Yyyy-mm-dd HH:MM:SS ') from dual

Reports the system date in timestamp data type format.

Select Systimestamp from dual;

Querying the currently logged on user

Select username from user_users

Show user

View table structure (field data type)

Desc user_users

Querying tables owned by the current user

Select table_name from User_tables

Forgot Password Login

Open the cmd window and enter Sqlplus/as SYSDBA

Remote connection

Gb/[email PROTECTED]/ORCL

Create a sequence

Create sequence sequence name

Start with start sequence

Increment by value per increment

Sequence name. Nextval (Next sequence)

Sequence name. Currval (current sequence)

Create a reply temp table data

Create global temporary table as another table data on commit preserve rows; (You can copy data from the original table, which is what is commonly used.) )



Add a field comment (Table note)

Comment on column tmp_xian.id is ' primary key '

Comment on column tmp_xian.name is ' Maximum user name '

COMMENT on table TABLENAME is ' user table ';


VARCHAR2 Maximum length 4000bite char (2000bite)


View the first 500 rows of data

SELECT * FROM T_pub_download_detail where rownum<500

COUNT (*) and COUNT (1) Efficiency results are the same as count (name) statistic Name column is not empty record

Select COUNT (*) from table; COUNT (1)

Date datetime (accurate to seconds) timestamp (accurate to fractional seconds)


Union Table link (filter duplicate records) union ALL (simple 2 tables result merge) union ALL high efficiency


LTRIM (String): Remove the space to the left of the string.   RTRIM (String): Removes the space to the right of the string.   TRIM (String): Removes the spaces at the beginning and end of the string. ALLTRIM (String): Remove the space between the left and right sides of the string.


This article is from the "fairy height of the cold" blog, please be sure to keep this source http://xian521.blog.51cto.com/9240575/1585677

Some SQL commands commonly used by Oracle

Related Article

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.