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
  • 下一頁

相關文章

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.