- Barajar
ActivarDesactivar
- Alphabetizar
ActivarDesactivar
- Frente Primero
ActivarDesactivar
- Ambos lados
ActivarDesactivar
- Leer
ActivarDesactivar
Leyendo...
Cómo estudiar sus tarjetas
Teclas de Derecha/Izquierda: Navegar entre tarjetas.tecla derechatecla izquierda
Teclas Arriba/Abajo: Colvea la carta entre frente y dorso.tecla abajotecla arriba
Tecla H: Muestra pista (3er lado).tecla h
Tecla N: Lea el texto en voz.tecla n
Boton play
Boton play
75 Cartas en este set
- Frente
- Atrás
- 3er lado (pista)
(SQL ORDER BY Keyword) How to sort the result-set in ascending or descending order?
|
The ORDER BY keyword is used to sort the result-set in ascending or descending order.
|
|
(SQL ORDER BY Keyword) The ORDER BY keyword sorts the records in ascending order by default.
|
To sort the records in descending order, use the DESC keyword.
|
|
(SQL ORDER BY Keyword) What is the ORDER BY Syntax?
|
SELECT column1, column2, ...
FROM table_name ORDER BY column1, column2, ... ASC|DESC; |
|
(SQL ORDER BY Keyword) Demo Database
|
Below is a selection from the "Customers" table in the Northwind sample database:
|
|
(SQL ORDER BY Keyword) (Example) The following SQL statement selects all customers from the "Customers" table, sorted by the "Country" column:
|
SELECT * FROM Customers
ORDER BY Country; |
|
(SQL ORDER BY Keyword) (ORDER BY DESC Example) The following SQL statement selects all customers from the "Customers" table, sorted DESCENDING by the "Country" column:
|
SELECT * FROM Customers
ORDER BY Country DESC; |
|
(SQL ORDER BY Keyword) (ORDER BY Several Columns Example) The following SQL statement selects all customers from the "Customers" table, sorted by the "Country" and the "CustomerName" column. This means that it orders by Country, but if some rows have the same Country, it orders them by CustomerName:
|
SELECT * FROM Customers
ORDER BY Country, CustomerName; |
|
(SQL ORDER BY Keyword) (ORDER BY Several Columns Example 2) The following SQL statement selects all customers from the "Customers" table, sorted ascending by the "Country" and descending by the "CustomerName" column:
|
SELECT * FROM Customers
ORDER BY Country ASC, CustomerName DESC; |
|
(SQL INSERT INTO Statement) How to insert new records in a table?
|
The INSERT INTO statement is used to insert new records in a table.
|
|
(SQL INSERT INTO Statement) What is the INSERT INTO Syntax?
|
It is possible to write the INSERT INTO statement in two ways:
|
|
(SQL INSERT INTO Statement) INSERT INTO Syntax 1
|
1. Specify both the column names and the values to be inserted.
|
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...); |
(SQL INSERT INTO Statement) INSERT INTO Syntax 2
|
2. If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query. However, make sure the order of the values is in the same order as the columns in the table. Here, the INSERT INTO syntax would be as follows:
|
INSERT INTO table_name
VALUES (value1, value2, value3, ...); |
(SQL INSERT INTO Statement) Demo Database
|
Below is a selection from the "Customers" table in the Northwind sample database.
|
|
(SQL INSERT INTO Statement) INSERT INTO Example part 1. The following SQL statement inserts a new record in the "Customers" table.
|
INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country)
VALUES ('Cardinal','Tom B. Erichsen','Skagen 21','Stavanger','4006','Norway'); |
|
(SQL INSERT INTO Statement) INSERT INTO Example part 2
|
The selection from the "Customers" table will now look like this:
|
|
(SQL INSERT INTO Statement) Did you notice that we did not insert any number into the CustomerID field?
|
The CustomerID column is an auto-increment field and will be generated automatically when a new record is inserted into the table.
|
|
(SQL INSERT INTO Statement) Insert Data Only in Specified Columns
|
It is also possible to only insert data in specific columns.
|
The following SQL statement will insert a new record, but only insert data in the "CustomerName", "City", and "Country" columns (CustomerID will be updated automatically):
|
(SQL INSERT INTO Statement) Example part 1
|
INSERT INTO Customers (CustomerName, City, Country)
VALUES ('Cardinal', 'Stavanger', 'Norway'); |
|
(SQL INSERT INTO Statement) Example part 2
|
The selection from the "Customers" table will now look like this:
|
|
(SQL NULL Values) What is a NULL Value?
|
A field with a NULL value is a field with no value.
|
If a field in a table is optional, it is possible to insert a new record or update a record without adding a value to this field. Then, the field will be saved with a NULL value.
|
(SQL NULL Values) Note:
|
A NULL value is different from a zero value or a field that contains spaces.
|
A field with a NULL value is one that has been left blank during record creation!
|
(SQL NULL Values) How to Test for NULL Values?
|
It is not possible to test for NULL values with comparison operators, such as =, <, or <>.
|
We will have to use the IS NULL and IS NOT NULL operators instead.
|
(SQL NULL Values) IS NULL Syntax
|
SELECT column_names
FROM table_name WHERE column_name IS NULL; |
|
(SQL NULL Values) IS NOT NULL Syntax
|
SELECT column_names
FROM table_name WHERE column_name IS NOT NULL; |
|
(SQL NULL Values) Demo Database
|
Below is a selection from the "Customers" table in the Northwind sample database:
|
|
(SQL NULL Values) How the IS NULL operator is used?
|
The IS NULL operator is used to test for empty values (NULL values).
|
|
(SQL NULL Values) Example: The following SQL lists all customers with a NULL value in the "Address" field.
|
SELECT CustomerName, ContactName, Address
FROM Customers WHERE Address IS NULL; |
|
(SQL NULL Values) Tip:
|
Always use IS NULL to look for NULL values.
|
|
(SQL NULL Values) How the IS NOT NULL operator is used?
|
The IS NOT NULL operator is used to test for non-empty values (NOT NULL values).
|
|
(SQL NULL Values) Example: The following SQL lists all customers with a value in the "Address" field:
|
SELECT CustomerName, ContactName, Address
FROM Customers WHERE Address IS NOT NULL; |
|
(SQL UPDATE Statement) How the UPDATE statement is used?
|
The UPDATE statement is used to modify the existing records in a table.
|
|
(SQL UPDATE Statement) What is the UPDATE Syntax?
|
UPDATE table_name
SET column1 = value1, column2 = value2, ... WHERE condition; |
|
(SQL UPDATE Statement) Note: Be careful when updating records in a table! Notice the WHERE clause in the UPDATE statement.
|
The WHERE clause specifies which record(s) that should be updated.
|
If you omit the WHERE clause, all records in the table will be updated!
|
(SQL UPDATE Statement) Demo Database
|
Below is a selection from the "Customers" table in the Northwind sample database:
|
|
(SQL UPDATE Statement) Example: The following SQL statement updates the first customer (CustomerID = 1) with a new contact person and a new city.
|
UPDATE Customers
SET ContactName='Alfred Schmidt', City='Frankfurt' WHERE CustomerID=1; |
|
(SQL UPDATE Statement) Example part 2: The selection from the "Customers" table will now look like this:
|
|
|
(SQL UPDATE Statement) How to UPDATE Multiple Records?
|
It is the WHERE clause that determines how many records will be updated.
|
|
(SQL UPDATE Statement) Example: The following SQL statement will update the ContactName to "Juan" for all records where country is "Mexico":
|
UPDATE Customers
SET ContactName='Juan' WHERE Country='Mexico'; |
|
(SQL UPDATE Statement) Example part 2:
|
The selection from the "Customers" table will now look like this:
|
|
(SQL UPDATE Statement) Update Warning!
|
Be careful when updating records.
|
If you omit the WHERE clause, ALL records will be updated!
|
(SQL UPDATE Statement) Update Warning! (Example)
|
/*You should Restore the Database after finishing this example*/
UPDATE Customers SET ContactName='Juan'; |
|
(SQL UPDATE Statement) Example part 2
|
The selection from the "Customers" table will now look like this:
|
|
(SQL DELETE Statement) How the DELETE statement is used?
|
The DELETE statement is used to delete existing records in a table.
|
|
(SQL DELETE Statement) DELETE Syntax
|
DELETE FROM table_name WHERE condition;
|
|
(SQL DELETE Statement) Note: Be careful when deleting records in a table! Notice the WHERE clause in the DELETE statement.
|
The WHERE clause specifies which record(s) should be deleted.
|
If you omit the WHERE clause, all records in the table will be deleted!
|
(SQL DELETE Statement) Demo Database
|
Below is a selection from the "Customers" table in the Northwind sample database:
|
|
(SQL DELETE Statement) Example: The following SQL statement deletes the customer "Alfreds Futterkiste" from the "Customers" table:
|
DELETE FROM Customers WHERE CustomerName='Alfreds Futterkiste';
|
|
(SQL DELETE Statement) Example part 2:
|
The "Customers" table will now look like this:
|
|
(SQL DELETE Statement) How to delete All Records?
|
It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact:
|
DELETE FROM table_name;
|
(SQL DELETE Statement) Example: The following SQL statement deletes all rows in the "Customers" table, without deleting the table:
|
DELETE FROM Customers;
|
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) How the SELECT TOP clause is used?
|
The SELECT TOP clause is used to specify the number of records to return.
|
The SELECT TOP clause is useful on large tables with thousands of records. Returning a large number of records can impact performance.
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) Note:
|
Not all database systems support the SELECT TOP clause.
|
MySQL supports the LIMIT clause to select a limited number of records, while Oracle uses FETCH FIRST n ROWS ONLY and ROWNUM.
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) What is the SQL Server / MS Access Syntax?
|
SELECT TOP number|percent column_name(s)
FROM table_name WHERE condition; |
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) What is the MySQL Syntax?
|
SELECT column_name(s)
FROM table_name WHERE condition LIMIT number; |
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) What is the Oracle 12 Syntax?
|
SELECT column_name(s)
FROM table_name ORDER BY column_name(s) FETCH FIRST number ROWS ONLY; |
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) What is the Older Oracle Syntax?
|
SELECT column_name(s)
FROM table_name WHERE ROWNUM <= number; |
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) What is the Older Oracle Syntax (with ORDER BY)?
|
SELECT *
FROM (SELECT column_name(s) FROM table_name ORDER BY column_name(s)) WHERE ROWNUM <= number; |
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) Demo Database
|
Below is a selection from the "Customers" table in the Northwind sample database:
|
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) (Example) The following SQL statement selects the first three records from the "Customers" table (for SQL Server/MS Access):
|
SELECT TOP 3 * FROM Customers;
|
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) The following SQL statement shows the equivalent example for MySQL:
|
SELECT * FROM Customers LIMIT 3;
|
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) The following SQL statement shows the equivalent example for Oracle:
|
SELECT * FROM Customers
FETCH FIRST 3 ROWS ONLY; |
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) (SQL TOP PERCENT Example) The following SQL statement selects the first 50% of the records from the "Customers" table (for SQL Server/MS Access):
|
SELECT TOP 50 PERCENT * FROM Customers;
|
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) The following SQL statement shows the equivalent example for Oracle:
|
SELECT * FROM Customers
FETCH FIRST 50 PERCENT ROWS ONLY; |
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) ADD a WHERE CLAUSE
|
The following SQL statement selects the first three records from the "Customers" table, where the country is "Germany" (for SQL Server/MS Access):
|
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) (Example) ADD a WHERE CLAUSE
|
SELECT TOP 3 * FROM Customers
WHERE Country='Germany'; |
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) The following SQL statement shows the equivalent example for MySQL:
|
SELECT * FROM Customers
WHERE Country='Germany' LIMIT 3; |
|
(SQL TOP, LIMIT, FETCH FIRST or ROWNUM Clause) The following SQL statement shows the equivalent example for Oracle:
|
SELECT * FROM Customers
WHERE Country='Germany' FETCH FIRST 3 ROWS ONLY; |
|
(SQL MIN() and MAX() Functions) What does The MIN() function do?
|
The MIN() function returns the smallest value of the selected column.
|
|
(SQL MIN() and MAX() Functions) What does The MAX() function do?
|
The MAX() function returns the largest value of the selected column.
|
|
(SQL MIN() and MAX() Functions) What is the MIN() Syntax?
|
SELECT MIN(column_name)
FROM table_name WHERE condition; |
|
(SQL MIN() and MAX() Functions) What is the MAX() Syntax?
|
SELECT MAX(column_name)
FROM table_name WHERE condition; |
|
(SQL MIN() and MAX() Functions) Demodatabase
|
Below is a selection from the "Products" table in the Northwind sample database:
|
|
(SQL MIN() and MAX() Functions) MIN() Example. he following SQL statement finds the price of the cheapest product:
|
SELECT MIN(Price) AS SmallestPrice
FROM Products; |
|
(SQL MIN() and MAX() Functions) MAX() Example. The following SQL statement finds the price of the most expensive product:
|
SELECT MAX(Price) AS LargestPrice
FROM Products; |
|
SQL COUNT(), AVG() and SUM() Functions
|
Próximo
|
05 agosto 11:30 am
|