database fundamental
TRANSCRIPT
DDL: TRUNCATE
• deletes all data from a table in a very fast way • deletes the data inside the table and not the table itself • usually implies a subsequent COMMIT operation, i.e. • cannot be rolled back
DML: MERGE
• is used to combine the data of multiple tables • combines the INSERT and UPDATE elements • is defined in the SQL:2003 standard • some databases provided similar functionality via different
syntax, sometimes called "upsert"
DCL: Control
• The operations for which privileges may be granted to or revoked from a user or role apply to both the DDL/DML
• may include CONNECT, SELECT, INSERT, UPDATE, DELETE, EXECUTE, and USAGE
• SQLite does not have any DCL commands as it does not have usernames or logins. Instead, SQLite depends on file system permissions to define who can open and access a database
Functions
• definition: function_name(parameter) —> output
• usage: SELECT function_name(parameter);
Aggregrations
avg(X) returns the average value of all non-NULL X within a group
count(X) returns a count of the number of times that X is not NULL in a group
max(X) returns the maximum value of all values in the group
min(X) returns the minimum non-NULL value of all values in the group
sum(X) return sum of all non-NULL values in the group
A balance: $ 1000
B balance: $ 1000
1) A transfer $100 to B 2) C transfer $1 000 to A
C balance: $ 1 000 000
Reference
• https://en.wikipedia.org/wiki/SQL • https://en.wikipedia.org/wiki/Database • https://en.wikipedia.org/wiki/ACID • https://www.sqlite.org/lang.html • https://en.wikipedia.org/wiki/Join_(SQL) • http://coding-geek.com/how-databases-work/ • http://blog.dancrisan.com/a-tiny-intro-to-database-systems • http://berb.github.io/diploma-thesis/original/060_index.html • https://en.wikipedia.org/wiki/CAP_theorem • https://github.com/numetriclabz/awesome-db • https://github.com/rxin/db-readings • http://bigocheatsheet.com/ • https://en.wikipedia.org/wiki/BNF • https://dylanninin.com/blog/2013/10/26/oracle_dba.html