Retrieving Data Flashcards
1
Q
SQL Statement and Case
A
– SQL statements are not case-sensitive.
2
Q
Use of White Space
A
– All extra white space within a SQL statement is ignored when that statement is processed.
3
Q
How Retrieve Top 5 rows in different DBMS (MS SQL Server, DB2, Oracle, MySQL, MariaDB, PostgreSQL, SQLite)
A
- MS SQL Server – SELECT TOP 5 prod_name FROM Products;
- DB2 – SELECT prod_name FROM Products FETCH FIRST 5 ROWS ONLY;
- ORACLE – SELECT prod_name FROM Products WHERE ROWNUM ≤5;
- MySQL, MariaDB, PostgreSQL, SQLite - SELECT prod_name FROM Products LIMIT 5; - to get 5 next rows - SELECT prod_name FROM Products LIMIT 5 OFFSET 5;
LIMIT 4 OFFSET 3 = LIMIT3,4 → Yes, they are reversed, so be careful
4
Q
Entire Line Comment
A
#
5
Q
Multiline Comment
A
/* smth */
6
Q
SELECT уник
A
SELECT DISTINCT