数据库

DB2 教程

December 5, 2020
,
DB2

DB2 教程 排序 ORDER BY SELECT select_list FROM table_name ORDER BY expression1 [ASC | DESC], expression2 [ASC | DESC], ... 过滤 DISTINCT SELECT DISTINCT column_name1, column_name2, ... FROM table_name; IN WHERE publisher_id IN (100, 103, 105) LIMIT 行 LIMIT LIMIT 10 OFFSET 5; 也可以写成: LIMIT 5, 10 FETCH SELECT title, rating FROm books ORDER BY rating DESC FETCH FIRST 10 ROWS ONLY; 下一页: SELECT title, rating FROm books ORDER BY rating DESC OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY; DB2 类型 Integers 支持三种:SMALLINT (-32768 ~ 32767)、INT (31 bits)、BIGINT (63 bits)。示例: ...

Oracle 教程

December 5, 2020
,
Oracle

Oracle 教程 select 语句 语句文本的书写不区分大小写。(但字符串在作为值的时候要注意大小写) 连接操作符: select lastname || 'work in' || department_id from tablename; 过滤数据 DISTINCT column_1、column_2、column_3 共同决定一条唯一的记录: SELECT DISTINCT column_1, column_2, column_3 FROM table_name; FETCH Oracle 没有 LIMIT,使用 FETCH 实现相同效果: SELECT product_name, quantity FROM inventories INNER JOIN products USING (product_id) ORDER BY quantity DESC FETCH NEXT 5 ROWS ONLY; 更多语法: FETCH FIRST 5 PERCENT ROWS ONLY:返回前 5% 百分比 OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY: 跳过前 10 条,返回下 10 条 IN WHERE salesman_id IN (54, 55, 56) WHERE status IN ('Pending', 'Canceled') WHERE status NOT IN ('Shipped', 'Canceled') BETWEEN WHERE order_date BETWEEN DATE '2016-12-01' AND DATE '2016-12-31' WHERE standard_cost NOT BETWEEN 500 AND 600 LIKE %: 匹配字符串的 0 或者任意多字符 _: 匹配一个字符 WHERE last_name LIKE 'St%' IS NULL NULL 和 ''、0 是不同的。 ...