第五章 使用SQL獲取數據

          Posted on 2006-11-10 20:16 黑夜ちつ獨行者 閱讀(262) 評論(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



          ??????

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


          網站導航:
           
          主站蜘蛛池模板: 财经| 邯郸县| 榆林市| 石台县| 潼南县| 保亭| 阿坝| 五原县| 台中县| 巫山县| 平湖市| 新竹县| 古田县| 唐山市| 新源县| 克山县| 呼图壁县| 寿光市| 屏南县| 观塘区| 江都市| 荔波县| 山西省| 保德县| 上蔡县| 桐柏县| 民勤县| 吉林市| 南雄市| 新竹县| 奇台县| 阿图什市| 昌吉市| 清原| 平昌县| 英德市| 宿州市| 承德县| 五华县| 盖州市| 河池市|