SQL keyword documentation
(keyword string)
| 838 | |
| 839 | // SQL keyword documentation |
| 840 | func getKeywordDocumentation(keyword string) string { |
| 841 | docs := map[string]string{ |
| 842 | "SELECT": "**SELECT** - Retrieves data from one or more tables.\n\n```sql\nSELECT column1, column2 FROM table_name;\n```", |
| 843 | "FROM": "**FROM** - Specifies the table(s) to retrieve data from.\n\n```sql\nSELECT * FROM users;\n```", |
| 844 | "WHERE": "**WHERE** - Filters rows based on a condition.\n\n```sql\nSELECT * FROM users WHERE active = true;\n```", |
| 845 | "JOIN": "**JOIN** - Combines rows from two or more tables based on a related column.\n\n```sql\nSELECT * FROM orders JOIN customers ON orders.customer_id = customers.id;\n```", |
| 846 | "LEFT": "**LEFT JOIN** - Returns all rows from the left table and matched rows from the right table.\n\n```sql\nSELECT * FROM orders LEFT JOIN customers ON orders.customer_id = customers.id;\n```", |
| 847 | "RIGHT": "**RIGHT JOIN** - Returns all rows from the right table and matched rows from the left table.\n\n```sql\nSELECT * FROM orders RIGHT JOIN customers ON orders.customer_id = customers.id;\n```", |
| 848 | "INNER": "**INNER JOIN** - Returns rows that have matching values in both tables.\n\n```sql\nSELECT * FROM orders INNER JOIN customers ON orders.customer_id = customers.id;\n```", |
| 849 | "OUTER": "**OUTER JOIN** - Returns all rows when there is a match in either table.\n\n```sql\nSELECT * FROM orders FULL OUTER JOIN customers ON orders.customer_id = customers.id;\n```", |
| 850 | "GROUP": "**GROUP BY** - Groups rows that have the same values in specified columns.\n\n```sql\nSELECT department, COUNT(*) FROM employees GROUP BY department;\n```", |
| 851 | "ORDER": "**ORDER BY** - Sorts the result set by specified columns.\n\n```sql\nSELECT * FROM users ORDER BY name ASC;\n```", |
| 852 | "HAVING": "**HAVING** - Filters groups based on a condition (used with GROUP BY).\n\n```sql\nSELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*) > 5;\n```", |
| 853 | "LIMIT": "**LIMIT** - Restricts the number of rows returned.\n\n```sql\nSELECT * FROM users LIMIT 10;\n```", |
| 854 | "OFFSET": "**OFFSET** - Skips a specified number of rows before returning results.\n\n```sql\nSELECT * FROM users LIMIT 10 OFFSET 20;\n```", |
| 855 | "INSERT": "**INSERT** - Adds new rows to a table.\n\n```sql\nINSERT INTO users (name, email) VALUES ('John', 'john@example.com');\n```", |
| 856 | "UPDATE": "**UPDATE** - Modifies existing rows in a table.\n\n```sql\nUPDATE users SET name = 'Jane' WHERE id = 1;\n```", |
| 857 | "DELETE": "**DELETE** - Removes rows from a table.\n\n```sql\nDELETE FROM users WHERE id = 1;\n```", |
| 858 | "CREATE": "**CREATE** - Creates database objects (tables, indexes, views, etc.).\n\n```sql\nCREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(100));\n```", |
| 859 | "DROP": "**DROP** - Removes database objects.\n\n```sql\nDROP TABLE users;\n```", |
| 860 | "ALTER": "**ALTER** - Modifies database objects.\n\n```sql\nALTER TABLE users ADD COLUMN age INT;\n```", |
| 861 | "TRUNCATE": "**TRUNCATE** - Removes all rows from a table quickly.\n\n```sql\nTRUNCATE TABLE logs;\n```", |
| 862 | "WITH": "**WITH** - Defines a Common Table Expression (CTE).\n\n```sql\nWITH active_users AS (SELECT * FROM users WHERE active = true)\nSELECT * FROM active_users;\n```", |
| 863 | "UNION": "**UNION** - Combines result sets of two queries (removes duplicates).\n\n```sql\nSELECT name FROM employees UNION SELECT name FROM contractors;\n```", |
| 864 | "EXCEPT": "**EXCEPT** - Returns rows from the first query that are not in the second.\n\n```sql\nSELECT name FROM employees EXCEPT SELECT name FROM managers;\n```", |
| 865 | "INTERSECT": "**INTERSECT** - Returns rows that appear in both queries.\n\n```sql\nSELECT name FROM employees INTERSECT SELECT name FROM managers;\n```", |
| 866 | "CASE": "**CASE** - Provides conditional logic in SQL.\n\n```sql\nSELECT name, CASE WHEN age >= 18 THEN 'Adult' ELSE 'Minor' END FROM users;\n```", |
| 867 | "WHEN": "**WHEN** - Specifies a condition in a CASE expression.\n\n```sql\nCASE WHEN status = 'active' THEN 'Yes' ELSE 'No' END\n```", |
| 868 | "THEN": "**THEN** - Specifies the result when a CASE condition is true.\n\n```sql\nCASE WHEN status = 'active' THEN 'Yes' END\n```", |
| 869 | "ELSE": "**ELSE** - Specifies the default result in a CASE expression.\n\n```sql\nCASE WHEN x > 0 THEN 'Positive' ELSE 'Non-positive' END\n```", |
| 870 | "END": "**END** - Ends a CASE expression or block.\n\n```sql\nCASE WHEN x > 0 THEN 'Positive' ELSE 'Non-positive' END\n```", |
| 871 | "AND": "**AND** - Combines conditions (all must be true).\n\n```sql\nSELECT * FROM users WHERE active = true AND age >= 18;\n```", |
| 872 | "OR": "**OR** - Combines conditions (at least one must be true).\n\n```sql\nSELECT * FROM users WHERE status = 'active' OR status = 'pending';\n```", |
| 873 | "NOT": "**NOT** - Negates a condition.\n\n```sql\nSELECT * FROM users WHERE NOT deleted;\n```", |
| 874 | "IN": "**IN** - Checks if a value matches any value in a list.\n\n```sql\nSELECT * FROM users WHERE status IN ('active', 'pending');\n```", |
| 875 | "BETWEEN": "**BETWEEN** - Checks if a value is within a range.\n\n```sql\nSELECT * FROM orders WHERE amount BETWEEN 100 AND 500;\n```", |
| 876 | "LIKE": "**LIKE** - Pattern matching with wildcards (% and _).\n\n```sql\nSELECT * FROM users WHERE name LIKE 'John%';\n```", |
| 877 | "IS": "**IS** - Tests for NULL values.\n\n```sql\nSELECT * FROM users WHERE deleted_at IS NULL;\n```", |
| 878 | "NULL": "**NULL** - Represents a missing or unknown value.\n\n```sql\nSELECT * FROM users WHERE email IS NOT NULL;\n```", |
| 879 | "AS": "**AS** - Creates an alias for a column or table.\n\n```sql\nSELECT name AS user_name FROM users u;\n```", |
| 880 | "DISTINCT": "**DISTINCT** - Returns only unique values.\n\n```sql\nSELECT DISTINCT status FROM orders;\n```", |
| 881 | "COUNT": "**COUNT** - Counts the number of rows.\n\n```sql\nSELECT COUNT(*) FROM users;\n```", |
| 882 | "SUM": "**SUM** - Calculates the sum of values.\n\n```sql\nSELECT SUM(amount) FROM orders;\n```", |
| 883 | "AVG": "**AVG** - Calculates the average of values.\n\n```sql\nSELECT AVG(salary) FROM employees;\n```", |
| 884 | "MIN": "**MIN** - Returns the minimum value.\n\n```sql\nSELECT MIN(price) FROM products;\n```", |
| 885 | "MAX": "**MAX** - Returns the maximum value.\n\n```sql\nSELECT MAX(price) FROM products;\n```", |
| 886 | "OVER": "**OVER** - Defines a window for window functions.\n\n```sql\nSELECT name, salary, ROW_NUMBER() OVER (ORDER BY salary DESC) FROM employees;\n```", |
| 887 | "PARTITION": "**PARTITION BY** - Divides rows into partitions for window functions.\n\n```sql\nSELECT dept, name, RANK() OVER (PARTITION BY dept ORDER BY salary) FROM employees;\n```", |
| 888 | "ROW_NUMBER": "**ROW_NUMBER()** - Assigns unique sequential numbers to rows.\n\n```sql\nSELECT name, ROW_NUMBER() OVER (ORDER BY name) FROM users;\n```", |
| 889 | "RANK": "**RANK()** - Assigns ranks with gaps for ties.\n\n```sql\nSELECT name, RANK() OVER (ORDER BY score DESC) FROM players;\n```", |
| 890 | "DENSE_RANK": "**DENSE_RANK()** - Assigns ranks without gaps for ties.\n\n```sql\nSELECT name, DENSE_RANK() OVER (ORDER BY score DESC) FROM players;\n```", |
| 891 | "LAG": "**LAG()** - Accesses data from a previous row.\n\n```sql\nSELECT date, value, LAG(value) OVER (ORDER BY date) AS prev_value FROM metrics;\n```", |
| 892 | "LEAD": "**LEAD()** - Accesses data from a following row.\n\n```sql\nSELECT date, value, LEAD(value) OVER (ORDER BY date) AS next_value FROM metrics;\n```", |
| 893 | "MERGE": "**MERGE** - Performs INSERT, UPDATE, or DELETE based on conditions.\n\n```sql\nMERGE INTO target USING source ON target.id = source.id\nWHEN MATCHED THEN UPDATE SET target.value = source.value\nWHEN NOT MATCHED THEN INSERT (id, value) VALUES (source.id, source.value);\n```", |
| 894 | "ROLLUP": "**ROLLUP** - Creates subtotals and grand totals in GROUP BY.\n\n```sql\nSELECT region, product, SUM(sales) FROM orders GROUP BY ROLLUP(region, product);\n```", |
| 895 | "CUBE": "**CUBE** - Creates all possible subtotal combinations in GROUP BY.\n\n```sql\nSELECT region, product, SUM(sales) FROM orders GROUP BY CUBE(region, product);\n```", |
| 896 | "GROUPING": "**GROUPING SETS** - Specifies multiple grouping sets in one query.\n\n```sql\nSELECT region, product, SUM(sales) FROM orders GROUP BY GROUPING SETS((region), (product), ());\n```", |
| 897 | "FETCH": "**FETCH** - Limits rows returned (SQL standard alternative to LIMIT).\n\n```sql\nSELECT * FROM users ORDER BY id FETCH FIRST 10 ROWS ONLY;\n```", |
no outgoing calls