第五章 使用SQL獲取數據

          Posted on 2006-11-10 20:16 黑夜ちつ獨行者 閱讀(264) 評論(0)  編輯  收藏
          5.1???返回所有列
          ?????????select???*from???表名;

          5.2???指定目標數據庫
          ?????????select???*from???scott.emp;

          5.3???返回單列
          ?????????select???列名???from???表名;
          ?????????舉例:select???name???from???student;
          ?????????????????????select???student.name???from???student;(在存在多個表的時候用)

          5.4??????返回多列
          ?????????select???列1???列2???列3???from???表名;
          ?????????舉例:select???studentid,name,age???from???student;

          5.5??????使用別名
          ??????????語法:?select???列1???as???列名?,??列2???as???列名?? from??表名???as???表名;
          ?????????????????或??select??T.?列1???as???列名?,?T.?列2???as???列名?? from??表名???as???T;
          ???
          ???????????舉例:select???studentid???as???stuid?,name???as???stuname???from???student???as???class;
          ????????????語句返回的列名為stuid和stuname??

          5.6?????? 連接字符串
          ???????????????oracle使用 || 來連接;

          5.7????????數據排序
          ????????????排序的值可以是字母、數字、時間等;
          ????????????語法:
          ??????????????????select???列1,列2???from???表???order???by???列1???asc;
          ??????????????????(按照列1中的值升序排列,其中asc?可以忽略)?
          ??????????????????select???列1,列2???from???表???order???by???列1???desc;?????
          ??????????????????(按照列1中的值降序排列,其中desc不?可以忽略)?

          5.8??????使用distinct排除重復數據
          ???????????????語法:select distinct?? 列1???from???表;
          ???????????????例:select???distinct???name???from???student;



          5.9



          ??????

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 上饶县| 新泰市| 白水县| 贵阳市| 元谋县| 民乐县| 东阿县| 肥西县| 台前县| 吴桥县| 湖北省| 茂名市| 田林县| 石门县| 体育| 万山特区| 孝感市| 海兴县| 郧西县| 桃园市| 泰宁县| 南澳县| 黄大仙区| 佛山市| 比如县| 大石桥市| 汉寿县| 贺州市| 大英县| 普定县| 工布江达县| 伊川县| 孟津县| 周宁县| 苏尼特右旗| 左权县| 永清县| 治县。| 岢岚县| 万山特区| 古田县|