Oracle_DAY 01 operation statement

Source: Internet
Author: User

Oracle_DAY 01 operation statement SQL> enter the oracle operation environment to query data -- DB -- orders Table External table is the basic unit of data storage in the database. The basic unit of data storage in the table is a row of table name-marker table Header -- table data description View table structure by table Name -- desc table Name ------------------ ID employee ID LAST_NAME Name FIRST_NAME Name USERID # user description START_DATE employment date COMMENTS employee remarks MANAGER_ID leader employee id title Position DEPT_ID Department No. SALARY monthly SALARY COMMISSION_PCT: all columns selected, some rows selected projection: Some columns selected, all rows selected table join: data comes from multiple tables, and the connection between tables is queried:. from Statement 1. query the data of a field from the table select field from the table; select salary from s_emp; build the environment: SQL script <1> upload the script to the corresponding server; <2> run the script: @ path/Script Name 2. query multiple fields and columns first_name salary out select first_name, salary from s_emp; 3. list the values of all fields in the table as select id, first_name ...; * Indicates all field names. select * from s_emp; 4. the mathematical calculation of fields calculates the annual salary of each person in the select salary * 12 from s_emp; the priority can be changed with parentheses 12 * salary + 10012 * (salary + 100) 1/20. 5 select 1/2 from dual; 5. the field alias follows the field name and select first_name name, 12 * salary yearsal from s_emp; the alias has special characters: select first_name name, 12 * salary "year sal" from s_emp; 6. how does SQL express the string 'A' in SQL? '''hello world' = equals 7. string connection --- oracle unique | first_name last_name salaryselect first_name, last_name, salary from s_emp; select first_name | last_name, salary from s_emp; add an underline in first_name and last_name select first_name | last_name, salary from s_emp; add a single quotation mark in first_name and last_name select first_name | ''' | last_name, salary from s_emp; unable to translate single quotes --- escape single quotes select first_name | ''' | last_name, salary from s_emp; two single quotes express one single quotes concatenate one double quotes between fitst_name and last_name select first_name | ''' | last_name from s_emp; 8. processing of NULL values monthly salary * 12*(1 + Commission/100) select salary * 12, salary * (1 + commission_pct/100) * 12 from s_emp; the NULL value and any value are both NULLNULL value processing functions: nvl (parameter 1, parameter 2) parameter 1: value to be processed or field parameter 2: if parameter 1 is NULL, return the value of parameter 2. If parameter 1 is not NULL, return the value of parameter 1. Note: parameter 1 and parameter 2 must have the same type as select salary * 12, salary * nvl (1 + commission_pct/100) * 12, 0) from s_emp; // logic errorNULL should process select salary * 12, salary * (1 + nvl (commission_pct, 0)/100) * 12 yearsal from s_emp; put first_name and manager_id. If manager_id is NULL,-1 select first_name, nvl (manager_id,-1) from s_emp; 9 is displayed. distinct display show all the wages select salary from s_emp; different wages --- disinctselect distinct salary from s_emp; select distinct title from s_emp; multiple fields select distinct salary, id from s_emp; select first_name, last_name, title from s_emp; select dinstinct last_name, title from s_emp;

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.