ff9947108c684a950413964576d175ab2da905af
API/CodeSamples/1-Million-Record-View.md
| ... | ... | @@ -1,24 +1,115 @@ |
| 1 | -#Changing Decimal Type Precision |
|
| 1 | +#1 Million Record View |
|
| 2 | 2 | |
| 3 | 3 | ##About |
| 4 | 4 | |
| 5 | 5 | Below is the SQL sample to create a View with 1 million records using the Northwind example database. This query can be used to load test your application with before you send it out to production. |
| 6 | 6 | |
| 7 | +##SQL Server |
|
| 7 | 8 | |
| 8 | -## What To Change |
|
| 9 | +```sql |
|
| 10 | +CREATE View [1MOrders] AS |
|
| 11 | +SELECT TOP 1000000 |
|
| 12 | + [Orders].[OrderID] |
|
| 13 | + ,[CustomerID] |
|
| 14 | + ,[OrderDate] |
|
| 15 | + ,[RequiredDate] |
|
| 16 | + ,[ShippedDate] |
|
| 17 | + ,[ShipVia] |
|
| 18 | + ,[Freight] |
|
| 19 | + ,[ShipName] |
|
| 20 | + ,[ShipAddress] |
|
| 21 | + ,[ShipCity] |
|
| 22 | + ,[ShipRegion] |
|
| 23 | + ,[ShipPostalCode] |
|
| 24 | + ,[ShipCountry] |
|
| 25 | + ,[Order Details].[UnitPrice] |
|
| 26 | + ,[Quantity] |
|
| 27 | + ,[Discount] |
|
| 28 | + ,[Products].[ProductID] |
|
| 29 | + ,[ProductName] |
|
| 30 | + ,[QuantityPerUnit] |
|
| 31 | + ,[UnitsInStock] |
|
| 32 | + ,[UnitsOnOrder] |
|
| 33 | + ,[ReorderLevel] |
|
| 34 | + ,[Discontinued] |
|
| 35 | + ,[CategoryName] |
|
| 36 | + ,[Description] |
|
| 9 | 37 | |
| 38 | +FROM Orders |
|
| 39 | +JOIN [Order Details] ON [Order Details].[OrderID] = [Orders].[OrderID] |
|
| 40 | +CROSS JOIN Products |
|
| 41 | +CROSS JOIN Categories |
|
| 42 | +GO |
|
| 43 | +``` |
|
| 44 | + |
|
| 45 | +##Oracle |
|
| 10 | 46 | |
| 47 | +```sql |
|
| 48 | +DROP VIEW NORTHWIND."1MOrders"; |
|
| 11 | 49 | |
| 12 | -DECIMAL(18,6) to NUMERIC(22,8) |
|
| 13 | -```c# |
|
| 14 | -List<KeyValuePair<string, string>> typeOverrides = AdHocContext.Driver.NativeTypesOverrides; |
|
| 15 | -for (int i = 0; i < typeOverrides.Count; i++) |
|
| 16 | - if (typeOverrides[i].Key == "Decimal") |
|
| 17 | - { |
|
| 18 | - typeOverrides[i] = new KeyValuePair<string, string>(typeOverrides[i].Key, "NUMERIC(22,8)"); |
|
| 19 | - break; |
|
| 20 | - } |
|
| 21 | -AdHocContext.Driver.NativeTypesOverrides = typeOverrides; |
|
| 50 | +CREATE OR REPLACE FORCE VIEW NORTHWIND."1MOrders" |
|
| 51 | +( |
|
| 52 | + "OrderID" |
|
| 53 | + ,"CustomerID" |
|
| 54 | + ,"OrderDate" |
|
| 55 | + ,"RequiredDate" |
|
| 56 | + ,"ShippedDate" |
|
| 57 | + ,"ShipVia" |
|
| 58 | + ,"Freight" |
|
| 59 | + ,"ShipName" |
|
| 60 | + ,"ShipAddress" |
|
| 61 | + ,"ShipCity" |
|
| 62 | + ,"ShipRegion" |
|
| 63 | + ,"ShipPostalCode" |
|
| 64 | + ,"ShipCountry" |
|
| 65 | + ,"UnitPrice" |
|
| 66 | + ,"Quantity" |
|
| 67 | + ,"Discount" |
|
| 68 | + ,"ProductID" |
|
| 69 | + ,"ProductName" |
|
| 70 | + ,"QuantityPerUnit" |
|
| 71 | + ,"UnitsInStock" |
|
| 72 | + ,"UnitsOnOrder" |
|
| 73 | + ,"ReorderLevel" |
|
| 74 | + ,"Discontinued" |
|
| 75 | + ,"CategoryName" |
|
| 76 | + ,"Description" |
|
| 77 | +) |
|
| 78 | +AS |
|
| 79 | + SELECT Orders.OrderID |
|
| 80 | + ,CustomerID |
|
| 81 | + ,OrderDate |
|
| 82 | + ,RequiredDate |
|
| 83 | + ,ShippedDate |
|
| 84 | + ,ShipVia |
|
| 85 | + ,Freight |
|
| 86 | + ,ShipName |
|
| 87 | + ,ShipAddress |
|
| 88 | + ,ShipCity |
|
| 89 | + ,ShipRegion |
|
| 90 | + ,ShipPostalCode |
|
| 91 | + ,ShipCountry |
|
| 92 | + ,Order_Details.UnitPrice |
|
| 93 | + ,Quantity |
|
| 94 | + ,Discount |
|
| 95 | + ,Products.ProductID |
|
| 96 | + ,ProductName |
|
| 97 | + ,QuantityPerUnit |
|
| 98 | + ,UnitsInStock |
|
| 99 | + ,UnitsOnOrder |
|
| 100 | + ,ReorderLevel |
|
| 101 | + ,Discontinued |
|
| 102 | + ,CategoryName |
|
| 103 | + ,Description |
|
| 104 | + FROM Orders |
|
| 105 | + JOIN "ORDER_DETAILS" ON "ORDER_DETAILS"."ORDERID" = "ORDERS"."ORDERID" |
|
| 106 | + CROSS JOIN PRODUCTS |
|
| 107 | + CROSS JOIN CATEGORIES |
|
| 108 | + where rownum <= 1000000; |
|
| 22 | 109 | |
| 110 | +CREATE OR REPLACE SYNONYM NORTHWIND."Orders Qry" FOR NORTHWIND."1MOrders"; |
|
| 23 | 111 | ``` |
| 24 | 112 | |
| 113 | + |
|
| 114 | + |
|
| 115 | + |