Oracle筆記:資料操作

來源:互聯網
上載者:User

在進行資料操作之前,首先需要有幾張完整的表。建立兩張表,分別為tableA和tableB

create table tableA(id integer,name varchar(25),age number);
insert into tableA values('101','Jack','25');
insert into tableA values('102','mike','22');
insert into tableA values('103','amy','23');

create table tableB(id integer,class number,grade number);
insert into tableB values('101','3','1');
insert into tableB values('104','4','2');
insert into tableB values('105','3','2');

結果如下:
650) this.width=650;" height=281>
1、 查詢空欄位

首先在tableA加一條ID為空白的記錄,如所示
650) this.width=650;" height=248>
查詢空欄位(null)
select * from 表名 where 欄位名 is null;
select * from tableA where id is null;
650) this.width=650;" height=118>

如所示,ID為空白的那條記錄被查詢出來了。

2、ORDER BY 語句
ORDER BY 語句用於根據指定的列對結果集進行排序。
ORDER BY 語句預設按照升序對記錄進行排序。
如果希望按照降序對記錄進行排序,可以使用 DESC 關鍵字。
如果希望按照升序對記錄進行排序,可以使用 ASC 關鍵字。
select * from 表名 order by 欄位名 DESC/ASC;
select * from tableA order by age desc;
select * from tableA order by age asc;
650) this.width=650;" height=295> 

  • 1
  • 2
  • 3
  • 下一頁

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.