Partial preview of the text
Download kuch bhi chate mat ser sdtesc and more Cheat Sheet Law of Obligations in PDF only on Docsity!
SQL COMMANDS SQL Commands The commands in SQL are called Queries and they are of two types: The statements which defines the structure of a database, create tables, specify their keys, indexes and soon : These are the queries which can be edited. Select, update and insert operation Ton ALTER TABLE table_name It is used to add columns to ADD column_name atype; |) 4 table in a databas: SELECT column_name(s) FROM table_name WHERE column_t = value_1 AND column_2 = value_2; SELECT column_name AS ‘Alias’ FROM table_name; SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value_1 AND value_2; SELECT column_name, CASE WHEN condition THEN ‘Result_1' WHEN condition THEN 'Result_2' ELSE 'Result_3’ END FROM table_name; SELECT COUNT (column_name) FROM table_name; CREATE TABLE table_name ( column_1 datatype, column_2 datatype, column_3 datatype i SELECT column_name, COUNT (*) FROM table_name GROUP BY GROUP BY column_name; SELECT column_name, COUNT (*) FROM table_name GROUP BY column_name HAVING COUNT(*) > value; eek LS INNER JOIN ay UR a NOT NULL Itis an operator that is used to combine two conditions It is an keyword in SQL that is used to rename a column or table using an alias name Itis an operator used to filter the result within a certain range It is a statement used to create different outputs inside a SELECT statement ORDER BY be l8 yi Bled) | It is a function that takes the name of a column as argument and counts the number of rows when the column is not NULL Itis used to create a new table in a database and specify the name of the table and columns inside it It is an clause in SQL used for aggregate functions in collaboration with the SELECT statement eae ea | a It is used in SQL because the WHERE keyword cannot be used in aggregating functions SELECT column_name(s) FROM table_1 JOIN table_2 ON table_1.column_name = table_2.column_name; INSERT INTO table_name (column_1, column_2, column _3) VALUES (value_1, ‘value_2', value_3); SELECT column_name(s) FROM table_name WHERE column_name |S NULL; SELECT column_name(s) FROM table_name WHERE column_name LIKE pattern; SELECT column_name(s) FROM table_name LIMIT number; SELECT MAX(column_name) FROM table_name; SELECT MIN(column_name) FROM table_name; SELECT column_ FROM table_name WHERE column_name = value _1 OR column_name = value_ 2: SELECT column_name FROM table_name ORDER BY column_name ASC | DESC; SELECT column_name(s) FROM table_1 LEFT JOIN table_2 ON table_i.column_name = table_2.column_name; SELECT ROUND(column_ name,integer) FROM table_name; SELECT column_name FROM table_name,; SELECT DISTINCT column_ name FROM table_name; SELECT SUM(column_name) FROM table_name,; Itis used to combine rows from different tables if the Jain condition goes TRUE Itis used to add new rows to a table It is a operator used with the WHERE clause to check for the empty values Itis an special operator used with the WHERE clause to search for a specific pattern ina column Itis a clause to specify the maximum number of rows the result set must have Itis a function that takes number of columns as an argument and return the largest value among them Itis a function that takes number of columns as an argument and return the smallest value among them Se eee ee Itis an operator that is used to filter the result set to contain only the rows where either condition is TRUE Itis a clause used to sort the result set by @ particular column either numerically or alphabetically It is sued to combine rows from different tables even if the condition is NOT TRUE Itis a function that takes the column name and a integer as an argument, and rounds the values ina column to the number of decimal places specified by an integer It is a statement that is used to fetch data from a database Itis used to specify that the statement is a query which returns unique values in specified columns Itis function used to return sum of values froma particular column UPDATE table_name SET some_column = some_ AAG value WHERE some_colu some_value; SELECT column_name(s) FROM table_name WHERE colummn_name operator value; WITH temporary_name AS ( SELECT * FROM table_name) SELECT * FROM temporary_name Description | command | syntax | Description Commands and syntax for te Mea ale asl Le Ll a ie ; eee Pe ale It is used to edit rows ina table mn= Itis a clause used to filter the result set to include the rows which where the condition is TRUE Itis used to store the result of a particular query in a temporary table using an alias WHERE column_name operato value; DELETE FROM table_name WHERE some_column = some_value; SELECT AVG(column_name) FROM table_name; Pea ey BOP dept Bele | from table t ou tae s ne aelg bear tae ee eam Cal 4 eae Bel med EBs me bl SELECT * FROM t To select all rows and columns from table t Eisen els as To select data in column cl from oe) ] [Rae Bo eci Reta el i Le) sle) 18) aoa elon |e) @] Meets Bue emi e) bs) id eta betel aoe Lg Rae e) fe) e) 0 -NaaL e oo la offset AOR het ae) ells a ea] SELECT cl, aggregate(c2) FROMt GROUP BY c1 MER cl Me ed ye Le ie ae itiytats i) Itis used to remove the rows from 4 table Itis used to aggregate a numeric column and return its average este am a 9 Commands and syntax for querying Ete tue Ce) le Rite el SELECT ci, c2 FROM tl INNER JOIN t2 on condition Select column ci and c2 from table 1 and perform an inner join between tl and t2 SELECT c1, c2 FROM t1 LEFT JOIN t2 on condition Select column cl and c2 from table tl and perform a left join between t1 SELECT ci, c2 FROM ti RIGHT JOIN t2 on condition Select column ci and c2 from table tl and perform a right join between tl and t2 SELECT ci, c2 FROM t1 FULL OUTER JOIN t2 on condition Select column ci and c2 from table tl and perform a full outer join between ti and t2 SELECT c1, c2 FROM t1 CROSS JOIN t2 Select column ci and c2 from table tl and produce a Cartesian product of rows in a table SELECT cl, c2 FROM t1, t2 Select column ci and c2 from table t] and produce a Cartesian product of rows in a table SELECT cl, aggregate(c2) aie GROUP BY cTHAVING condition eit Rte Me elie dat rte) tse lal Rig tee et tae mest SELECT ci, c2 FROM tl A INNER JOIN t2 B on condition Select column ci and c2 from table 1 and join it to itself using INNER FURTHERMORE: SQL Developer, SQL DBA Training Masters Program