SQL Hacks

Andrew Cumming, Gordon Russell

  • 出版商: O'Reilly
  • 出版日期: 2006-12-26
  • 售價: $1,250
  • 貴賓價: 9.5$1,188
  • 語言: 英文
  • 頁數: 412
  • 裝訂: Paperback
  • ISBN: 0596527993
  • ISBN-13: 9780596527990
  • 相關分類: SQL
  • 海外代購書籍(需單獨結帳)

買這商品的人也買了...

相關主題

商品描述

Description  

Whether you're running Access, MySQL, SQL Server, Oracle, or PostgreSQL, this book will help you push the limits of traditional SQL to squeeze data effectively from your database. The book offers 100 hacks -- unique tips and tools -- that bring you the knowledge of experts who apply what they know in the real world to help you take full advantage of the expressive power of SQL. You'll find practical techniques to address complex data manipulation problems. Learn how to:
  • Wrangle data in the most efficient way possible
  • Aggregate and organize your data for meaningful and accurate reporting
  • Make the most of subqueries, joins, and unions
  • Stay on top of the performance of your queries and the server that runs them
  • Avoid common SQL security pitfalls, including the dreaded SQL injection attack

Let SQL Hacks serve as your toolbox for digging up and manipulating data. If you love to tinker and optimize, SQL is the perfect technology and SQL Hacks is the must-have book for you.

 

Table of Contents

Credits  

Preface  

Chapter 1. SQL Fundamentals 

      1. Run SQL from the Command Line  

      2. Connect to SQL from a Program  

      3. Perform Conditional INSERTs  

      4. UPDATE the Database  

      5. Solve a Crossword Puzzle Using SQL  

      6. Don't Perform the Same Calculation Over and Over  

Chapter 2. Joins, Unions, and Views 

      7. Modify a Schema Without Breaking Existing Queries
      8. Filter Rows and Columns  

      9. Filter on Indexed Columns  

      10. Convert Subqueries to JOINs  

      11. Convert Aggregate Subqueries to JOINs  

      12. Simplify Complicated Updates  

      13. Choose the Right Join Style for Your Relationships  

      14. Generate Combinations  

Chapter 3. Text Handling 

      15. Search for Keywords Without LIKE  

      16. Search for a String Across Columns  

      17. Solve Anagrams  

      18. Sort Your Email  

Chapter 4. Date Handling 

      19. Convert Strings to Dates  

      20. Uncover Trends in Your Data  

      21. Report on Any Date Criteria  

      22. Generate Quarterly Reports  

      23. Second Tuesday of the Month  

Chapter 5. Number Crunching 

      24. Multiply Across a Result Set  

      25. Keep a Running Total  

      26. Include the Rows Your JOIN Forgot  

      27. Identify Overlapping Ranges  

      28. Avoid Dividing by Zero  

      29. Other Ways to COUNT  

      30. Calculate the Maximum of Two Fields  

      31. Disaggregate a COUNT  

      32. Cope with Rounding Errors  

      33. Get Values and Subtotals in One Shot  

      34. Calculate the Median  

      35. Tally Results into a Chart  

      36. Calculate the Distance Between GPS Locations  

      37. Reconcile Invoices and Remittances  

      38. Find Transposition Errors  

      39. Apply a Progressive Tax  

      40. Calculate Rank  

Chapter 6. Online Applications 

      41. Copy Web Pages into a Table  

      42. Present Data Graphically Using SVG  

      43. Add Navigation Features to Web Applications  

      44. Tunnel into MySQL from Microsoft Access  

      45. Process Web Server Logs  

      46. Store Images in a Database  

      47. Exploit an SQL Injection Vulnerability  

      48. Prevent an SQL Injection Attack  

Chapter 7. Organizing Data 

      49. Keep Track of Infrequently Changing Values  

      50. Combine Tables Containing Different Data  

      51. Display Rows As Columns  

      52. Display Columns As Rows  

      53. Clean Inconsistent Records  

      54. Denormalize Your Tables  

      55. Import Someone Else's Data  

      56. Play Matchmaker  

      57. Generate Unique Sequential Numbers  

Chapter 8. Storing Small Amounts of Data 

      58. Store Parameters in the Database  

      59. Define Personalized Parameters  

      60. Create a List of Personalized Parameters  

      61. Set Security Based on Rows  

      62. Issue Queries Without Using a Table  

      63. Generate Rows Without Tables  

Chapter 9. Locking and Performance 

      64. Determine Your Isolation Level  

      65. Use Pessimistic Locking  

      66. Use Optimistic Locking  

      67. Lock Implicitly Within Transactions  

      68. Cope with Unexpected Redo  

      69. Execute Functions in the Database  

      70. Combine Your Queries  

      71. Extract Lots of Rows  

      72. Extract a Subset of the Results  

      73. Mix File and Database Storage  

      74. Compare and Synchronize Tables  

      75. Minimize Bandwidth in One-to-Many Joins  

      76. Compress to Avoid LOBs  

Chapter 10. Reporting 

      77. Fill in Missing Values in a Pivot Table  

      78. Break It Down by Range  

      79. Identify Updates Uniquely  

      80. Play Six Degrees of Kevin Bacon  

      81. Build Decision Tables  

      82. Generate Sequential or Missing Data  

      83. Find the Top n in Each Group  

      84. Store Comma-Delimited Lists in a Column  

      85. Traverse a Simple Tree  

      86. Set Up Queuing in the Database  

      87. Generate a Calendar  

      88. Test Two Values from a Subquery  

      89. Choose Any Three of Five  

Chapter 11. Users and Administration 

      90. Implement Application-Level Accounts  

      91. Export and Import Table Definitions  

      92. Deploy Applications  

      93. Auto-Create Database Users  

      94. Create Users and Administrators  

      95. Issue Automatic Updates  

      96. Create an Audit Trail  

Chapter 12. Wider Access 

      97. Allow an Anonymous Account  

      98. Find and Stop Long-Running Queries  

      99. Don't Run Out of Disk Space  

      100. Run SQL from a Web Page  

Index  

商品描述(中文翻譯)

描述

無論您正在運行Access、MySQL、SQL Server、Oracle還是PostgreSQL,本書都將幫助您突破傳統SQL的極限,從您的數據庫中有效地提取數據。本書提供了100個技巧和工具,這些獨特的技巧和工具將帶給您專家的知識,他們在現實世界中應用他們所知道的知識,幫助您充分利用SQL的表達能力。您將找到解決複雜數據操作問題的實用技巧。學習如何:
- 以最有效的方式處理數據
- 聚合和組織數據以進行有意義和準確的報告
- 充分利用子查詢、聯接和聯合操作
- 監控查詢和運行它們的服務器的性能
- 避免常見的SQL安全陷阱,包括可怕的SQL注入攻擊

讓《SQL Hacks》成為您挖掘和操作數據的工具箱。如果您喜歡嘗試和優化,SQL是您的完美技術,而《SQL Hacks》是您必備的書籍。

目錄

- 致謝
- 前言
- 第1章 SQL基礎知識
- 從命令行運行SQL
- 從程序連接到SQL
- 執行有條件的插入操作
- 更新數據庫
- 使用SQL解決填字遊戲
- 避免重複計算
- 第2章 聯接、聯合和視圖
- 修改模式而不破壞現有查詢
- 過濾行和列
- 在索引列上過濾
- 將子查詢轉換為聯接
- 將聚合子查詢轉換為聯接
- 簡化複雜的更新操作
- 選擇適合您關係的聯接方式
- 生成組合
- 第3章 文本處理
- 在不使用LIKE的情況下搜索關鍵字
- 在多列中搜索字符串
- 解決字母重排問題
- 對郵件進行排序
- 第4章 日期處理
- 將字符串轉換為日期
- 發現數據中的趨勢
- 根據任何日期條件進行報告
- 生成季度報告
- 每月的第二個星期二
- 第5章 數字計算
- 在結果集中進行乘法
- 保持運行總數