当前位置: 代码迷 >> 综合 >> oracle学习笔记1-Writing basic sql select statments
  详细解决方案

oracle学习笔记1-Writing basic sql select statments

热度:19   发布时间:2024-01-09 14:36:54.0

摘录学习笔记,铭记前进的每一步.hoho

开始还是蛮简单的哦!

Objectives
 @List the capabilities of sql select staements
 @Exectue a basic select statement
 @Differentiate between sql statements and Isql *plus comamnds

Basic select statement
     selcet identifers what columns
      From identifers which table
Writing sql statements
     Sql statements are  not case sensitive
     Sql statements can be on one or more lines.
      Keywords cannot be abbreviated or split across lines.
     Clauses are usually placed on separate lines.
      Indents are used to enhance readability.
Column heading defaults
    @Isql *plus:
    Default heading justification:Center
    Default heading display:uppercase
    @sql *plus:
   Character and date column headings are left-justified.
    Number column headings are right-justified
  Default heading display:uppercase
Arithmetic expressions
   Create expressions with number and date data by using arithmetic operators.
   Add,subtract,multiply,divide
   e:select name,salary+300 from table;
Operator precedence
   Multiplication and divison take priority over addition and subtraction.
   Operators of the same priority are evaluated from left to right.
   Parentheeses are used to force prioritized evaluation and clarify statements.
  e:select name,salary*3+100 from table;
Defining a null values
   A null is a value that is unavailable,unassigned,unknown,or inapplicable.
   A null is not the same as zero  or a blank space.
Null values in Arithmetic expressions
   Arithmetic expressions containing a null value evaluate to null.
Defining a column alias
   A column alias:
   Renames a column heading.
   Is useful with calculations.
   Immediately follows the column name-there can also be the optional AS keyword between
   the column name and alias.
   e: select au_id author_id from table;  select au_id as autor_id from table;
      select au_id as "author_id" from table;
   Requires double quotation marks if it contains apaces or special characters or is case sensitive.
Concatenation operator
   A concatenation operator:
   Concatenates columns or characters strings to other columns.
   Is represented by two vertical bars(||).
   e:select au_name||' '||au_id from table;
   Create a resultant column that is a character expression.
Literal character strings
   A literal is a character ,a number ,or a date included in the select lis.
   Date and character literal values must be enclosed within single quotation  marks.
   Each character strings is output once for each row returned.
   e:select au_id,''' name si',au_name||' 'au_add from table;
Duplicate rows
   The default display fo queries is all rows,including duplicate rows.
   e:select au_id from table;
      select distinct au_id from table;
Sql and Isql *plus interaction

 

  相关解决方案