您的位置:首页 > 数据库 > Oracle

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

2005-12-14 23:59 615 查看
摘录学习笔记,铭记前进的每一步.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
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息