Preview

Sql-Cheat-Sheet

Satisfactory Essays
Open Document
Open Document
360 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Sql-Cheat-Sheet









SQL Facts
SQL stands for Structured Query Language
SQL is pronounced “sequel”
SQL is declarative language
SQL is used to access & manipulate data in databases
Top SQL DBs are MS SQL Server, Oracle, DB2, and MySQL
Database Definitions
RDBMS (Relational Database Management System) –
Software that stores and manipulates data arranged in relational database tables.
Table – A set of data arranged in columns and rows. The columns represent characteristics of stored data and the rows represent actual data entries.
How to select data from a table

SQL Commands Categories
Data Query Language (DQL)
 SELECT - Retrieve data from table(s)
Data Manipulation Language (DML)
 INSERT - Insert data into db table
 UPDATE - Update data in db table
 DELETE - Delete data from table
Data Definition Language (DDL)
 CREATE - Create db object (table, view, etc.)
 ALTER - Modify db object (table, view, etc.)
 DROP - Delete db object (table, view, etc.)
Data Control Language (DCL)
 GRANT - Assign privilege
 REVOKE - remove privilege
How to insert data in a table

SELECT
FROM
WHERE
Example:
SELECT FirstName, LastName, OrderDate
FROM Orders WHERE OrderDate > '10/10/2010'

INSERT INTO
() VALUES ()
Example:
INSERT INTO Orders
(FirstName, LastName, OrderDate) VALUES
('John', 'Smith', '10/10/2010')

How to update data in a table

How to delete data from a table

UPDATE
SET = , = , …
WHERE
Example:
UPDATE Orders
SET FirstName = 'John', LastName = 'Who' WHERE LastName='Wo'

DELETE FROM
WHERE
Example:
DELETE FROM Orders
WHERE OrderDate < '10/10/2010'

How to group data and use aggregates
SELECT , ()
FROM
WHERE
GROUP BY
Example:
SELECT LastName, SUM(OrderValue)
FROM Orders
WHERE OrderDate > '10/10/2010'
GROUP BY LastName

How to order data
SELECT
FROM
WHERE
ORDER BY
Example:
SELECT FirstName, LastName, OrderDate
FROM Orders
WHERE OrderDate > '10/10/2010'
ORDER BY OrderDate

You May Also Find These Documents Helpful

  • Good Essays

    The SELECT statement is the primary means of extracting data from database tables, and allows you to determine exactly which data you want to extract by means of different comparison operators used in the WHERE clause. This includes the use of specific "wild card" characters which allow you to search for character or number patterns within the data. You can also perform mathematical expressions within the SELECT statement to create derived output. The ORDER BY clause allows you to sort the output data in either ascending (the default) or descending order. Lab #5 will explore all of these applications of the SELECT statement.…

    • 1559 Words
    • 7 Pages
    Good Essays
  • Satisfactory Essays

    PT2520 Unit7Labs Tramil

    • 330 Words
    • 1 Page

    4. What is SQL language? The programming language used to manipulate data and data objects in a relational database.…

    • 330 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    pt2520 assignment 1

    • 466 Words
    • 2 Pages

    Let’s get the definition out the way, the standard meaning if you will SQL or “sequel” to some is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS). Now that we got that out the way, let’s get to the first question.…

    • 466 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    a guide to mysql ch 7

    • 1287 Words
    • 9 Pages

    During the CREATE TABLE command, but can be modified using the ADD PRIMARY KEY command…

    • 1287 Words
    • 9 Pages
    Powerful Essays
  • Satisfactory Essays

    SQL Queries

    • 423 Words
    • 2 Pages

    Given the table information above, if you were asked to create an Access query that showed the Student Name and Grade for all students taking a class in Room H201, what tables would you need and how would you link them together?…

    • 423 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Statistics Cheat Sheets

    • 1326 Words
    • 4 Pages

    * Yes because the p-value is less than 0.05 or No, because the p-value is greater than 0.05…

    • 1326 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Cheatsheet for Accounting

    • 686 Words
    • 3 Pages

    Are the assets which are easily convertible to cash sufficient to pay current liabilities? QR=CR/2…

    • 686 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Database concepts

    • 586 Words
    • 3 Pages

    Then the functional dependency A → C (which follows from 1 and 3 by the axiom of transitivity) is a transitive dependency.…

    • 586 Words
    • 3 Pages
    Good Essays
  • Good Essays

    DBA Notes For Module 3

    • 3528 Words
    • 11 Pages

    Explain how scientific observations led to the development of, and changes to, the periodic table.…

    • 3528 Words
    • 11 Pages
    Good Essays
  • Satisfactory Essays

    Flyer Envelope

    • 1145 Words
    • 12 Pages

    " Without SQL, websites will never have any way to handle Databases for data. "…

    • 1145 Words
    • 12 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Sql Hw

    • 546 Words
    • 3 Pages

    1. SELECT PARTNUMB, PARTDESC FROM PART Query1 | PARTNUMB | PARTDESC | AX12 | IRON | CX11 | MIXER | WHERE UNONHAND BETWEEN 100 AND 200 2. SELECT PARTNUMB, PARTDESC, (UNITPRCE*UNONHAND) ONHANDVALUE FROM PART WHERE VALUE >= 1000…

    • 546 Words
    • 3 Pages
    Satisfactory Essays
  • Better Essays

    My Sql Architecture

    • 1164 Words
    • 5 Pages

    and a thread is created for each. The threaded process is the heart of the executable pathway in…

    • 1164 Words
    • 5 Pages
    Better Essays
  • Good Essays

    Guide to SQL injection

    • 2874 Words
    • 12 Pages

    by the application. If programmers don’t take the time to validate the variables a user can enter…

    • 2874 Words
    • 12 Pages
    Good Essays
  • Powerful Essays

    SQL: Queries

    • 6089 Words
    • 25 Pages

    SQL-QUERIES 1. Display all the information of the EMP table? A) select * from emp; 2. Display unique Jobs from EMP table? A) select distinct job from emp; B) select unique job from emp; 3. List the emps in the asc order of their Salaries? A) select * from emp order by sal asc; 4. List the details of the emps in asc order of the Dptnos and desc of Jobs? A)select * from emp order by deptno asc,job desc; 5. Display all the unique job groups in the descending order? A)select distinct job from emp order by job desc; 6. Display all the details of all ‘Mgrs’ A)Select * from emp where empno in ( select mgr from emp) ; 7. List the emps who joined before 1981. A) select * from emp where hiredate < (’01-jan-81’); 8. List the Empno, Ename, Sal, Daily sal of all emps in the asc order of Annsal. A) select empno ,ename ,sal,sal/30,12*sal annsal from emp order by annsal asc; 9. Display the Empno, Ename, job, Hiredate, Exp of all Mgrs A) select empno,ename ,job,hiredate, months_between(sysdate,hiredate) exp…

    • 6089 Words
    • 25 Pages
    Powerful Essays
  • Satisfactory Essays

    13. In Addition we have some tagnometric Functions like SIN, COS, TAN, ACOS, ASIN, ATAN…

    • 479 Words
    • 2 Pages
    Satisfactory Essays

Related Topics