1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9925],{55:(e,t,n)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/glossary/sql",function(){return n(2471)}])},2471:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>r});var a=n(5105),s=n(1064),o=n(3907);let i={term:"SQL",definition:"SQL (Structured Query Language) is the standard way to interact with relational databases. It stores data in rows and columns, and you use commands like SELECT, INSERT, UPDATE, and DELETE to manage that data.",category:"Basic",howItWorks:"SQL works by defining structured schemas (tables, columns, relationships) and using statements to query or modify this data. It's declarative, meaning you specify what you want (e.g., rows matching a condition), and the database figures out the best way to get it. Different dialects exist, like MySQL, PostgreSQL, and SQL Server, but they share core functionality.",technicalDetails:"SQL is standardized by ANSI and ISO, though database vendors add their own extensions. Common commands include DDL (Data Definition Language) statements to set up tables or indexes, and DML (Data Manipulation Language) statements like SELECT, INSERT, UPDATE, and DELETE. Some systems also offer procedural extensions (e.g., PL/pgSQL) for advanced logic on the server side.",syntax:"-- Common SQL operations:\n\n-- 1. Querying data\nSELECT \n first_name,\n last_name,\n email,\n EXTRACT(YEAR FROM created_at) AS join_year\nFROM users\nWHERE status = 'active'\nGROUP BY first_name, last_name, email, join_year\nHAVING COUNT(*) > 1\nORDER BY join_year DESC\nLIMIT 10;\n\n-- 2. Modifying data\nINSERT INTO users (first_name, last_name, email)\nVALUES ('John', 'Doe', '[email protected]');\n\nUPDATE users\nSET status = 'inactive'\nWHERE last_login < NOW() - INTERVAL '1 year';\n\nDELETE FROM users\nWHERE status = 'deleted';\n\n-- 3. Joining multiple tables\nSELECT \n u.first_name,\n u.last_name,\n o.order_id,\n p.product_name,\n o.order_date\nFROM users u\nJOIN orders o ON u.user_id = o.user_id\nJOIN order_items oi ON o.order_id = oi.order_id\nJOIN products p ON oi.product_id = p.product_id\nWHERE o.status = 'completed';\n\n-- 4. Aggregates\nSELECT\n DATE_TRUNC('month', order_date) AS month,\n COUNT(DISTINCT user_id) AS unique_customers,\n SUM(total_amount) AS revenue,\n AVG(items_count) AS avg_items_per_order\nFROM orders\nGROUP BY month\nORDER BY month DESC;",supportedPlatforms:[{name:"MySQL",supported:!0,notes:"Popular open-source database with broad community support."},{name:"PostgreSQL",supported:!0,notes:"Advanced open-source system with extensive feature set."},{name:"SQL Server",supported:!0,notes:"Microsoftâs enterprise solution with T-SQL extensions."},{name:"SQLite",supported:!0,notes:"Lightweight, file-based database engine often used in small-scale applications."},{name:"Redshift",supported:!0,notes:"Amazonâs data warehouse solution built on PostgreSQL."},{name:"Snowflake",supported:!0,notes:"Cloud-based data warehouse that uses SQL for querying and management."},{name:"BigQuery",supported:!0,notes:"Google Cloudâs large-scale data warehouse that uses a variant of SQL."},{name:"ClickHouse",supported:!0,notes:"Column-oriented database designed for analytics, using a dialect of SQL."}],bestPractices:["Keep table and column names consistent and clear","Normalize data where sensible, but watch for over-normalization","Use indexes to speed up frequent queries","Rely on parameterized queries to prevent SQL injection"],commonPitfalls:["Forgetting WHERE clauses in UPDATE or DELETE statements","Relying too heavily on SELECT * instead of specifying columns","Not considering indexing strategy for large tables","Mixing different SQL dialect features without checking compatibility sources"],advancedTips:["Explore window functions (OVER, PARTITION BY) for complex aggregations","Use CTEs (WITH clauses) to structure large queries more readably","Leverage stored procedures or functions for repeatable logic","Employ query execution plans to fine-tune performance"],relatedTerms:[{term:"RDBMS",href:"/glossary/rdbms",definition:"Relational Database Management Systems, the softw
1are that implements SQL."},{term:"NoSQL",href:"/glossary/nosql",definition:"Non-relational databases that often use JSON instead of SQL schemas."}]},r=()=>(0,a.jsx)(s.A,{term:i.term,definition:i.definition,children:(0,a.jsx)(o.A,{...i})})}},e=>{var t=t=>e(e.s=t);e.O(0,[5598,3870,6752,6112,4582,636,6593,8792],()=>t(55)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.