原來Oracle有這種語法,SQL Server沒有這語法
https://www.oracletutorial.com/oracle-basics/oracle-order-by/
而且是ANSI SQL:2003語法
https://en.wikipedia.org/wiki/Order_by
2020年6月6日 星期六
2019年1月2日 星期三
不同資料庫SQL Script語法轉換器
線上版
http://www.sqlines.com/online
軟體版(免安裝)
http://www.sqlines.com/download
SQLines SQL Converter is an open source tool (Apache License 2.0) that helps you convert database schema (DDL), queries and DML statements, views, stored procedures, packages, functions and triggers.
原始碼
https://github.com/dmtolpeko/sqlines
http://www.sqlines.com/online
軟體版(免安裝)
http://www.sqlines.com/download
SQLines SQL Converter is an open source tool (Apache License 2.0) that helps you convert database schema (DDL), queries and DML statements, views, stored procedures, packages, functions and triggers.
原始碼
https://github.com/dmtolpeko/sqlines
2016年4月25日 星期一
SQL Server、db2和Oracle收集最新統計資訊
SQL Server:
DBCC UPDATEUSAGE
=> exec sys.sp_MsForEachTable 'select ''?'', count(*) from ? '
=> 把EXEC sys.sp_MSforeachtable結果存入暫存資料表
DB2:
RUNSTATS
=> select TABNAME,CARD from syscat.tables
Oracle:
DBMS_STATS
=> select table_name,num_rows from all_tables
REF:Oracle manually update statistics on all tables
Keyword: Updates statistics
DBCC UPDATEUSAGE
=> exec sys.sp_MsForEachTable 'select ''?'', count(*) from ? '
=> 把EXEC sys.sp_MSforeachtable結果存入暫存資料表
DB2:
RUNSTATS
=> select TABNAME,CARD from syscat.tables
Oracle:
DBMS_STATS
=> select table_name,num_rows from all_tables
REF:Oracle manually update statistics on all tables
Keyword: Updates statistics
2016年4月17日 星期日
SQL Fiddle線上執行SQL語法的網站
http://sqlfiddle.com
自己做的DEMO:
http://sqlfiddle.com/#!6/8ac02/1/0
另外作者有把程式碼Open Source
程式碼
https://github.com/jakefeasel/sqlfiddle2
程式碼(舊版)
https://github.com/jakefeasel/sqlfiddle
自己做的DEMO:
http://sqlfiddle.com/#!6/8ac02/1/0
另外作者有把程式碼Open Source
程式碼
https://github.com/jakefeasel/sqlfiddle2
程式碼(舊版)
https://github.com/jakefeasel/sqlfiddle
2016年4月16日 星期六
各種資料庫Select first rows的方式
SQL - Select first 10 rows only? - Stack Overflow
http://stackoverflow.com/questions/1891789/sql-select-first-10-rows-only
http://stackoverflow.com/questions/1891789/sql-select-first-10-rows-only
各種資料庫List All Tables
How to List All Tables and Describe Tables in Oracle, MySQL, DB2 and PostgreSQL
http://onewebsql.com/blog/list-all-tables
http://onewebsql.com/blog/list-all-tables
2016年4月10日 星期日
使用PIVOT函數建立各月份銷售統計報表
2014-08故意沒把NULL改成0
2014-09使用ISNULL函數,其他月份使用COALESCE函數
COALESCE函數是ANSI SQL-92標準,ISNULL函數不是標準
另外SQL Server 2005之後才支援PIVOT函數
Oracle 11g之後也支援函數
MySQL沒有PIVOT函數,要使用GROUP_CONCAT
ref:
比較 ISNULL() 函數以及 COALESCE() 函數
SQL server : Replacing NULL with 0 in a query - Stack Overflow
Databases that support PIVOT/UNPIVOT syntax:
下載Adventure Works 2014 Sample Databases:
https://msftdbprodsamples.codeplex.com/releases/view/125550
訂閱:
文章 (Atom)