Experimental Finance, IEOR. Mike Lipkin, Alexander Stanton

Size: px
Start display at page:

Download "Experimental Finance, IEOR. Mike Lipkin, Alexander Stanton"

Transcription

1 Experimental Finance, IEOR Mike Lipkin, Alexander Stanton

2 Housekeeping Make sure your tables/views/functions are prefixed with UNI ID One zip file please, containing other files Describe your process Project groups: Everyone settled? Experimental Finance Mike Lipkin, Alexander Stanton Page 2

3 Outline Some SQL queries you can help me with Creating tables and temporary tables Creating Indices Experimental Finance Mike Lipkin, Alexander Stanton Page 3

4 Strike calculation SELECT strike/1000 FROM option_price_view Strike Correct: SELECT CAST(strike AS FLOAT)/ FROM option_price_view Use the function xf.dbo.formatstrike()!! Experimental Finance Mike Lipkin, Alexander Stanton Page 4

5 Count number of options by week for a month SELECT DATEPART(week,date), COUNT(DISTINCT bestbid) FROM option_price_2000_02 GROUP BY DATEPART(week,date) Experimental Finance Mike Lipkin, Alexander Stanton Page 5

6 Count number of options by week for a month SELECT DATEPART(week,date), COUNT(DISTINCT bestbid) FROM option_price_2000_02 GROUP BY DATEPART(week,date) counting only distinct best bids probably not useful count(*) for shorthand makes it impossible to mistake DISTINCT SELECT DATEPART(week,date), COUNT(*) FROM option_price_2000_02 GROUP BY DATEPART(week,date) Week Count Experimental Finance Mike Lipkin, Alexander Stanton Page 6

7 Count number of options by week for a month SELECT DATEPART(week,date), COUNT(DISTINCT bestbid) FROM option_price_2000_02 GROUP BY DATEPART(week,date) counting only distinct best bids probably not useful count(*) for shorthand makes it impossible to mistake DISTINCT SELECT DATEPART(week,date), COUNT(*) FROM option_price_2000_02 GROUP BY DATEPART(week,date) First and last week are hardly ever complete This Matters (and not many pointed this out) Week Count Experimental Finance Mike Lipkin, Alexander Stanton Page 7

8 Query Comparison SELECT ticker FROM security s LEFT JOIN security_price sp ON s.securityid=sp.securityid AND sp.date=' WHERE sp.closeprice is null SELECT ticker FROM security s LEFT JOIN security_price sp ON s.securityid=sp.securityid WHERE sp.closeprice is null AND sp.date=' ' Many assertions and theories that they do one thing or the other TEST IT! Experimental Finance Mike Lipkin, Alexander Stanton Page 8

9 How many unique tickers traded on a given day? SELECT count(distinct ticker) SELECT count(distinct ticker) FROM security s FROM security s LEFT JOIN security_price sp LEFT JOIN security_price sp ON s.securityid=sp.securityid ON s.securityid=sp.securityid WHERE sp.date = ' AND sp.date = WHERE sp.securityid is not null SELECT count(distinct ticker) SELECT count(distinct ticker) FROM security s FROM security s LEFT JOIN security_price sp WHERE s.ticker NOT IN ON s.securityid=sp.securityid (SELECT s1.ticker FROM security s1 AND sp.date = ' LEFT JOIN security_price sp ON s1.securityid=sp.securityid AND sp.date= WHERE sp.securityid is null) Experimental Finance Mike Lipkin, Alexander Stanton Page 9

10 How many unique tickers traded on a given day? SELECT count(distinct ticker) SELECT count(distinct ticker) FROM security s FROM security s LEFT JOIN security_price sp LEFT JOIN security_price sp ON s.securityid=sp.securityid ON s.securityid=sp.securityid WHERE sp.date = ' AND sp.date = WHERE sp.securityid is not null SELECT count(distinct ticker) SELECT count(distinct ticker) FROM security s FROM security s LEFT JOIN security_price sp WHERE s.ticker NOT IN ON s.securityid=sp.securityid (SELECT s1.ticker FROM security s1 AND sp.date = ' LEFT JOIN security_price sp ON s1.securityid=sp.securityid AND sp.date= WHERE sp.securityid is null) Experimental Finance Mike Lipkin, Alexander Stanton Page 10

11 The right way SELECT count(distinct ticker) FROM security s INNER JOIN security_price sp ON s.securityid=sp.securityid WHERE sp.date =' Only use OUTER JOINS when: Data is required from a table even when there is none in the joining table Using a WHERE clause that satisfies a NULL condition (Set theory: relative compliment), e.g.: SELECT count(distinct ticker) FROM security s LEFT OUTER JOIN security_price sp ON s.securityid=sp.securityid WHERE sp.date is null Experimental Finance Mike Lipkin, Alexander Stanton Page 11

12 SQL Performance Are they the same? Is one faster than the other? SELECT TOP 1 opv1.strike, opv2.strike FROM option_price_view opv1 INNER JOIN option_price_view opv2 ON opv2.securityid=opv1.securityid AND opv2.date=opv1.date AND opv2.expiration=opv1.expiration AND opv2.strike<opv1.strike ORDER BY opv1.strike DESC SELECT TOP 1 opv1.strike, opv1.strike FROM option_price_view opv1 WHERE opv1.strike<(select top 1 strike from option_price_view opv2 WHERE opv2.securityid=opv1.securityid AND opv2.date=opv1.date AND opv2.expiration=opv1.expiration AND opv2.strike=opv1.strike ORDER BY strike DESC) ORDER BY opv1.strike DESC Experimental Finance Mike Lipkin, Alexander Stanton Page 12

13 SQL Performance Are they the same? Is one faster than the other? SELECT TOP 1 opv1.strike, opv2.strike FROM option_price_view opv1 INNER JOIN option_price_view opv2 ON watch ordering! opv2.securityid=opv1.securityid AND opv2.date=opv1.date AND opv2.expiration=opv1.expiration AND opv2.strike<opv1.strike ORDER BY opv1.strike DESC, opv2.strike DESC 20 sec. SELECT TOP 1 opv1.strike, opv1.strike FROM option_price_view opv1 WHERE opv1.strike<(select top 1 strike from option_price_view opv2 WHERE opv2.securityid=opv1.securityid AND opv2.date=opv1.date AND opv2.expiration=opv1.expiration AND opv2.strike=opv1.strike ORDER BY strike DESC) ORDER BY opv1.strike DESC, opv2.strike DESC 4+ hours Experimental Finance Mike Lipkin, Alexander Stanton Page 13

14 SQL Performance Better yet: for readability and cross-checking: SELECT strike =dbo.formatstrike(opv1.strike), strikebelow =dbo.formatstrike(opv2.strike), strikeabove =dbo.formatstrike(opv3.strike) FROM option_price_2005_01 opv1 INNER JOIN option_price_2005_01 opv2 ON opv2.securityid=opv1.securityid AND opv2.date=opv1.date AND opv2.expiration=opv1.expiration AND opv2.strike<opv1.strike INNER JOIN option_price_2005_01 opv3 ON opv3.securityid=opv1.securityid AND opv3.date=opv1.date AND opv3.expiration=opv1.expiration AND opv3.strike>opv1.strike Strike Below Above Experimental Finance Mike Lipkin, Alexander Stanton Page 14

15 SQL Performance Better yet: for readability and cross-checking: SELECT strike =dbo.formatstrike(opv1.strike), strikebelow =dbo.formatstrike(opv2.strike), strikeabove =dbo.formatstrike(opv3.strike) FROM option_price_2005_01 opv1 INNER JOIN option_price_2005_01 opv2 ON opv2.securityid=opv1.securityid AND opv2.date=opv1.date AND opv2.expiration=opv1.expiration AND opv2.strike<opv1.strike INNER JOIN option_price_2005_01 opv3 ON opv3.securityid=opv1.securityid AND opv3.date=opv1.date AND opv3.expiration=opv1.expiration AND opv3.strike>opv1.strike WHAT IS WRONG HERE? Strike Below Above Experimental Finance Mike Lipkin, Alexander Stanton Page 15

16 SQL Performance CORRECTED: SELECT strike =dbo.formatstrike(opv1.strike), strikebelow =dbo.formatstrike(max(opv2.strike)), strikeabove =dbo.formatstrike(min(opv3.strike)) FROM option_price_2005_01 opv1 INNER JOIN option_price_2005_01 opv2 ON opv2.securityid=opv1.securityid AND opv2.date=opv1.date AND opv2.expiration=opv1.expiration AND opv2.strike<opv1.strike INNER JOIN option_price_2005_01 opv3 ON opv3.securityid=opv1.securityid AND opv3.date=opv1.date AND opv3.expiration=opv1.expiration AND opv3.strike>opv1.strike GROUP BY opv1.strike Strike Below Above Experimental Finance Mike Lipkin, Alexander Stanton Page 16

17 SQL Performance: WHERE clauses SELECT count(distinct ticker) FROM security s INNER JOIN security_price sp ON s.securityid=sp.securityid WHERE sp.date =' SELECT count(distinct ticker) FROM security s INNER JOIN security_price sp ON s.securityid=sp.securityid WHERE sp.date IS NOT NULL Experimental Finance Mike Lipkin, Alexander Stanton Page 17

18 SQL Performance: WHERE clauses SELECT count(distinct ticker) FROM security s INNER JOIN security_price sp ON s.securityid=sp.securityid WHERE sp.date =' seconds to find 8240 rows SELECT count(distinct ticker) FROM security s INNER JOIN security_price sp ON s.securityid=sp.securityid WHERE sp.date IS NOT NULL 17 seconds to go through 33 million rows Beware of functions in where clauses e.g. WHERE f(col1)>x - more on this later. Experimental Finance Mike Lipkin, Alexander Stanton Page 18

19 How many stocks trade at the beginning of the year? int = 1996 While(@Year < 2011) BEGIN as 'Year, COUNT(distinct SecurityID) as 'Securities FROM dbo.security_price WHERE Date = (select Top 1 Date FROM dbo.security_price WHERE YEAR(date) +1 END Experimental Finance Mike Lipkin, Alexander Stanton Page 19 Year Securities

20 How many stocks trade at the beginning of the year? int = 1996 While(@Year < 2011) BEGIN as 'Year, COUNT(distinct SecurityID) as 'Securities FROM dbo.security_price WHERE Date = (select Top 1 Date FROM dbo.security_price WHERE YEAR(date) +1 END 30 Queries + hardcoding values, never good Experimental Finance Mike Lipkin, Alexander Stanton Page 20 Year Securities

21 How many stocks trade at the beginning of the year? SELECT "stocks"=count(distinct securityid),date FROM SECURITY_PRICE s WHERE date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' and ' ') [..] GROUP BY date ORDER BY date 16 Queries, a little better Experimental Finance Mike Lipkin, Alexander Stanton Page 21

22 How many stocks trade at the beginning of the year? SELECT "stocks"=count(distinct securityid),date FROM SECURITY_PRICE s WHERE date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' and ' ') or date= (select Top 1(date) from Security_Price where date between ' and ' ') [..] GROUP BY date ORDER BY date top 1 date between 1/1 and 1/5 is not precise. Takes +/- 4 minutes Experimental Finance Mike Lipkin, Alexander Stanton Page 22

23 How many stocks trade at the beginning of the year? SELECT COUNT(DISTINCT s.ticker) FROM [..] WHERE sn1.date = (SELECT MIN(date) FROM [..] WHERE MONTH(date)=1 and DAY(date)<=3) Experimental Finance Mike Lipkin, Alexander Stanton Page 23

24 How many stocks trade at the beginning of the year? SELECT COUNT(DISTINCT s.ticker) FROM [..] WHERE sn1.date = (SELECT MIN(date) FROM [..] WHERE MONTH(date)=1 and DAY(date)<=3) - Friday New Years day causes missing data - Do not necessarily restrict your data to speed up queries. Without the DAY() restriction it would not be much slower. - Look for several orders of magnitude when optimizing queries Experimental Finance Mike Lipkin, Alexander Stanton Page 24

25 How many stocks trade at the beginning of the year? SELECT FROM security_price WHERE month(date)=1 GROUP BY year(date) ORDER BY year(date) min(date) AS FirstDayOfYear, count(securityid) AS NumOfStocksTrading Year Count Experimental Finance Mike Lipkin, Alexander Stanton Page 25

26 How many stocks trade at the beginning of the year? SELECT FROM security_price WHERE month(date)=1 GROUP BY year(date) ORDER BY year(date) min(date) AS FirstDayOfYear, count(distinct securityid) AS NumOfStocksTrading Need to count distinct securities what else is wrong? Year Count Experimental Finance Mike Lipkin, Alexander Stanton Page 26

27 How many stocks trade at the beginning of the year? SELECT FROM security_price WHERE month(date)=1 GROUP BY year(date) ORDER BY year(date) min(date) AS FirstDayOfYear, count(distinct securityid) AS NumOfStocksTrading Year Count Need to count distinct securities This counts all tickers that traded in the first month of each year. Not the first day of the year. Instead: SELECT YEAR(date), COUNT(DISTINCT securityid) FROM security_price WHERE date IN (SELECT min(date) [from SP] GROUP BY YEAR(date)) GROUP BY YEAR(date) Experimental Finance Mike Lipkin, Alexander Stanton Page 27

28 Close Prices SELECT date, ticker, closeprice FROM security s INNER JOIN security_price sp ON s.securityid=sp.securityid WHERE s.ticker = 'C AND year(sp.date) = '1999 Experimental Finance Mike Lipkin, Alexander Stanton Page 28

29 Close Prices SELECT date, ticker, closeprice FROM security s INNER JOIN security_price sp ON s.securityid=sp.securityid WHERE s.ticker = 'C AND year(sp.date) = ' Experimental Finance Mike Lipkin, Alexander Stanton Page 29

30 Adjustment Factor Exists on security_price, option_price SELECT closeprice*adjustmentfactor for consistent data SELECT closeprice*adjf/max(adjf) in a date range yields prices adjusted to the last date in the queried data set Experimental Finance Mike Lipkin, Alexander Stanton Page 30

31 At The Moneys NOT GOOD: SELECT s1.date,o.strike,s1.closeprice FROM security s INNER JOIN security_price s1 ON s.securityid=s1.securityid INNER JOIN option_price_2005_03 o ON s.securityid=o.securityid AND s1.date=o.date WHERE s.ticker='msft' AND ABS(s1.closeprice-dbo.formatStrike(o.strike))<=2.5 ORDER BY s1.date GOOD: SELECT [..] WHERE s.ticker='msft' AND ABS(S-K) = (SELECT MIN(ABS(S-K)) FROM [..] WHERE ID=ID and Date=Date) ORDER BY s1.date ATM: by now you know which one to use. If not, ask Mike during office hours or you will be sorry. Experimental Finance Mike Lipkin, Alexander Stanton Page 31

32 Summary Think about boundary conditions Validate and test start building your portfolio of checks and exclusions: -99 deltas Volume>0 Negative prices Implied Vols breaking down near expiration Interest rates Date ranges Once you understand and solve a data issue, package it and make sure you reuse it. Experimental Finance Mike Lipkin, Alexander Stanton Page 32

33 Summary Creating Tables and Indices Experimental Finance Mike Lipkin, Alexander Stanton Page 33

34 Introduction Create tables to: Store new information De-normalize tables Solve problems that cannot be addressed in a single query Speed up access to data that takes a long time to compute Store historical data sets for comparison Always prefix objects with your UNI ID when creating tables, functions, stored procedures Use proper naming conventions, not temp1 through temp68 In the lab, do not create tables with very large datasets!! Experimental Finance Mike Lipkin, Alexander Stanton Page 34

35 CREATE TABLE Syntax CREATE TABLE mytable ( ) mytableid INT NOT NULL, ticker VARCHAR(7) NOT NULL, description VARCHAR(255) NULL, type CHAR(2), istraded BIT NOT NULL, PRIMARY KEY(myTableID) Types: - INT, TINYINT, SMALLINT, BIGINT, DECIMAL, NUMERIC, FLOAT, REAL - MONEY - VARCHAR - BIT - DATETIME - TIMESTAMP (auto updates when a row is inserted/updated) - TEXT/BINARY/IMAGE Experimental Finance Mike Lipkin, Alexander Stanton Page 35

36 CHAR vs. VARCHAR CHAR: Fixed length, whether there is data or not Ticker CHAR(10) containing MSFT stored as MSFT Storage implications Microsoft SQL accepts WHERE ticker= MSFT - MANY DO NOT VARCHAR(size): variable length and stored as a byte array the size of the actual value Size specifies maximum size constraint unpredictable table size Slightly slower page retrieval Experimental Finance Mike Lipkin, Alexander Stanton Page 36

37 NUMERIC TYPES DECIMAL FLOAT REAL MONEY INT, BIGINT, TINYINT Be careful with exact and approximate numeric types Also: rounding errors moving from sql -> Excel, Matlab, C++ Experimental Finance Mike Lipkin, Alexander Stanton Page 37

38 Primary Keys Unique per row Cannot be NULL Can consist of one or more columns, e.g: PRIMARY KEY (securityid, date) Surrogate keys for Primary Keys Used for convenience Key does not represent inherent information Need a way to define the surrogate key: definition: myid INT NOT NULL IDENTITY(seed,increment) PRIMARY KEY e.g. myid INT NOT NULL IDENTITY(1,1) PRIMARY KEY Experimental Finance Mike Lipkin, Alexander Stanton Page 38

39 Inserting into tables INSERT INTO mytable (date, ticker, price) VALUES ( , MSFT, 20.5) SELECT securityid, date, ticker, closeprice INTO mytable FROM security INNER JOIN security_price ON [ ] BULK INSERT mytable FROM c:\data.txt Command for fast loading of data from text files Text File must reside on the server Can cause full table lock / no constraint checks IVY is set up this way automatically creates table with the correct columns and column types Experimental Finance Mike Lipkin, Alexander Stanton Page 39

40 Temporary Tables Temporary tables are fast, and very useful A table name starting with # implies a temporary table Only exist for the duration of the connection Stored in RAM unless size limitations force caching to disk Good idea to de-allocate the table using DROP #mytable when finished Can get corrupted - not good for anything beyond temporary storage CREATE TABLE #mytable(col1,col2, ) OR SELECT securityid, date, ticker, closeprice INTO #myothertable FROM security INNER JOIN security_price ON [ ] Experimental Finance Mike Lipkin, Alexander Stanton Page 40

41 INDEX Syntax CREATE UNIQUE CLUSTERED INDEX myindexname ON security_price (date, volume, ) There can only be one and only one CLUSTERED Index. The Directive tells the database to physically rearrange and store the data according to the index. Which of the queries below take advantage of the index? SELECT securityid from [SP] WHERE date>[x] AND volume>20,000,000 SELECT securityid from [SP] WHERE date>[y] AND volume>1,000 Indices take up space, potentially duplicating the storage used by the column(s) being indexed if all columns are included VIEWS can also be indexed Experimental Finance Mike Lipkin, Alexander Stanton Page 41

42 INDEX Examples CREATE UNIQUE CLUSTERED INDEX i1 ON option_price (date, security_id, strike, expiration, delta) CREATE UNIQUE INDEX i2 ON option_price (security_id, date, expiration, delta) SELECT * FROM option_price WHERE WHERE date > WHERE securityid = [MSFT] WHERE strike=25000 WHERE strike=25000 AND securityid=[msft] WHERE delta>40 AND delta<50 AND date> Experimental Finance Mike Lipkin, Alexander Stanton Page 42

43 Indices w.r.t. Functions If functions are used in the where clause, indices using that column cannot be used! (unless the index is relevant w.r.t. other columns.) SELECT * FROM security_price sp WHERE datepart(year, sp.date)=2004 (Much) better: SELECT * FROM security_price sp WHERE sp.date>= and sp.date< OR SELECT * FROM security_price sp WHERE DATEDIFF(dd,date,GETDATE())<=10 (Much) better: SELECT * FROM security_price sp WHERE sp.date>=dateadd(dd,-10,getdate()) Experimental Finance Mike Lipkin, Alexander Stanton Page 43

44 Indices Note: Be careful with dates WHERE sp.date>= AND sp.date< Expands to: WHERE sp.date>= :00:00 AND sp.date< :00:00 Experimental Finance Mike Lipkin, Alexander Stanton Page 44

45 Physical Data Retrieval, Covering Indices How the database retrieves data: Request is made for table data Index rapidly finds the physical row locator Loads the relevant page from disk (all columns) Appropriate columns are returned to the SELECT statement Covering indices: Have all data required to fulfill the SELECT statement. e.g.: CREATE UNIQUE INDEX myindexname ON option_price (securityid, date, expiration, strike) No second physical data read required Much faster, but of course query dependent Indices are very powerful and worth learning well Experimental Finance Mike Lipkin, Alexander Stanton Page 45

46 More fun stuff What is the best way to get a list of trade dates? When do options expire? When are Earnings? Deals and special settlements Experimental Finance Mike Lipkin, Alexander Stanton Page 46

47 More fun stuff What is the best way to get a list of trade dates? SELECT DISTINCT date FROM security_price When do options expire? When are Earnings? Deals and special settlements Experimental Finance Mike Lipkin, Alexander Stanton Page 47

48 More fun stuff What is the best way to get a list of trade dates? SELECT DISTINCT date FROM security_price When do options expire? Generally Friday Night at 5:30pm, third Friday of the month Index options (AM/PM) Good Friday they expire Thursday SELECT DISTINCT expiration FROM option_price_view When are Earnings? Deals and special settlements Experimental Finance Mike Lipkin, Alexander Stanton Page 48

49 More fun stuff What is the best way to get a list of trade dates? SELECT DISTINCT date FROM security_price When do options expire? Generally Friday Night at 5:30pm, third Friday of the month Index options (AM/PM) Good Friday they expire Thursday SELECT DISTINCT expiration FROM option_price_view When are Earnings? Pre-open Post close Intraday (generally trading is halted if it s a leaked announcement) Deals and special settlements Experimental Finance Mike Lipkin, Alexander Stanton Page 49

50 More fun stuff What is the best way to get a list of trade dates? SELECT DISTINCT date FROM security_price When do options expire? Generally Friday Night at 5:30pm, third Friday of the month Index options (AM/PM) Good Friday they expire Thursday SELECT DISTINCT expiration FROM option_price_view When are Earnings? Pre-open Post close Intraday (generally trading is halted if it s a leaked announcement) Deals and special settlements Options may pay out different number of shares of stock (See front month and leaps in APOL in DEC 2005) Experimental Finance Mike Lipkin, Alexander Stanton Page 50

51 Adjustment Factors For the problem sets, check IVYs reference for adjustment factors on the security_price, option_price and dividend tables. There are several different adjustment factors and they are used in different scenarios you need to understand them! We ll be covering these in more details next time Experimental Finance Mike Lipkin, Alexander Stanton Page 51

52 Coming Up Last important building block: Functions and Stored Procedures Experimental Finance Mike Lipkin, Alexander Stanton Page 52

Experimental Finance. IEOR Department. Mike Lipkin, Alexander Stanton

Experimental Finance. IEOR Department. Mike Lipkin, Alexander Stanton Experimental Finance IEOR Department Mike Lipkin, Alexander Stanton Housekeeping Lab/home connectivity? Problem Set 2 due next week groups allowed! Send in your groups with names and UNI IDs due next week

More information

Experimental Finance IEOR. Mike Lipkin, Alexander Stanton

Experimental Finance IEOR. Mike Lipkin, Alexander Stanton Experimental Finance IEOR Mike Lipkin, Alexander Stanton Outline Pivot tables System design and data integrity A Different kind of database Experimental Finance Mike Lipkin, Alexander Stanton Page 2 Pivot

More information

This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client

This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client Lab 2.0 - MySQL CISC3140, Fall 2011 DUE: Oct. 6th (Part 1 only) Part 1 1. Getting started This lab will introduce you to MySQL. Begin by logging into the class web server via SSH Secure Shell Client host

More information

Introduction to SQL Server 2005/2008 and Transact SQL

Introduction to SQL Server 2005/2008 and Transact SQL Introduction to SQL Server 2005/2008 and Transact SQL Week 4: Normalization, Creating Tables, and Constraints Some basics of creating tables and databases Steve Stedman - Instructor Steve@SteveStedman.com

More information

5. SQL Query Syntax 1. Select Statement. 6. CPS: Database Schema

5. SQL Query Syntax 1. Select Statement. 6. CPS: Database Schema 5. SQL Query Syntax 1. Select Statement 6. CPS: Database Schema Joined in 2016 Previously IT Manager at RSNWO in Northwest Ohio AAS in Computer Programming A+ Certification in 2012 Microsoft Certified

More information

ColdFusion Summit 2016

ColdFusion Summit 2016 ColdFusion Summit 2016 Building Better SQL Server Databases Who is this guy? Eric Cobb - Started in IT in 1999 as a "webmaster - Developer for 14 years - Microsoft Certified Solutions Expert (MCSE) - Data

More information

Basic SQL. Basic SQL. Basic SQL

Basic SQL. Basic SQL. Basic SQL Basic SQL Dr Fawaz Alarfaj Al Imam Mohammed Ibn Saud Islamic University ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation Basic SQL Structured

More information

Building Better. SQL Server Databases

Building Better. SQL Server Databases Building Better SQL Server Databases Who is this guy? Eric Cobb Started in IT in 1999 as a "webmaster Developer for 14 years Microsoft Certified Solutions Expert (MCSE) Data Platform Data Management and

More information

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language

Information Systems Engineering. SQL Structured Query Language DDL Data Definition (sub)language Information Systems Engineering SQL Structured Query Language DDL Data Definition (sub)language 1 SQL Standard Language for the Definition, Querying and Manipulation of Relational Databases on DBMSs Its

More information

Advanced SQL Tribal Data Workshop Joe Nowinski

Advanced SQL Tribal Data Workshop Joe Nowinski Advanced SQL 2018 Tribal Data Workshop Joe Nowinski The Plan Live demo 1:00 PM 3:30 PM Follow along on GoToMeeting Optional practice session 3:45 PM 5:00 PM Laptops available What is SQL? Structured Query

More information

Building Better. SQL Server Databases

Building Better. SQL Server Databases Building Better SQL Server Databases Who is this guy? Eric Cobb SQL Server Database Administrator MCSE: Data Platform MCSE: Data Management and Analytics 1999-2013: Webmaster, Programmer, Developer 2014+:

More information

SELECT Product.name, Purchase.store FROM Product JOIN Purchase ON Product.name = Purchase.prodName

SELECT Product.name, Purchase.store FROM Product JOIN Purchase ON Product.name = Purchase.prodName Announcements Introduction to Data Management CSE 344 Lectures 5: More SQL aggregates Homework 2 has been released Web quiz 2 is also open Both due next week 1 2 Outline Outer joins (6.3.8, review) More

More information

Introduction to Database Systems CSE 414

Introduction to Database Systems CSE 414 Introduction to Database Systems CSE 414 Lectures 4 and 5: Aggregates in SQL CSE 414 - Spring 2013 1 Announcements Homework 1 is due on Wednesday Quiz 2 will be out today and due on Friday CSE 414 - Spring

More information

BEGINNING T-SQL. Jen McCown MidnightSQL Consulting, LLC MinionWare, LLC

BEGINNING T-SQL. Jen McCown MidnightSQL Consulting, LLC MinionWare, LLC BEGINNING T-SQL Jen McCown MidnightSQL Consulting, LLC MinionWare, LLC FIRST: GET READY 1. What to model? 2. What is T-SQL? 3. Books Online (BOL) 4. Transactions WHAT TO MODEL? What kind of data should

More information

Basic SQL. Dr Fawaz Alarfaj. ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation

Basic SQL. Dr Fawaz Alarfaj. ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation Basic SQL Dr Fawaz Alarfaj Al Imam Mohammed Ibn Saud Islamic University ACKNOWLEDGEMENT Slides are adopted from: Elmasri & Navathe, Fundamentals of Database Systems MySQL Documentation MIDTERM EXAM 2 Basic

More information

Exact Numeric Data Types

Exact Numeric Data Types SQL Server Notes for FYP SQL data type is an attribute that specifies type of data of any object. Each column, variable and expression has related data type in SQL. You would use these data types while

More information

MySQL: an application

MySQL: an application Data Types and other stuff you should know in order to amaze and dazzle your friends at parties after you finally give up that dream of being a magician and stop making ridiculous balloon animals and begin

More information

Teradata SQL Features Overview Version

Teradata SQL Features Overview Version Table of Contents Teradata SQL Features Overview Version 14.10.0 Module 0 - Introduction Course Objectives... 0-4 Course Description... 0-6 Course Content... 0-8 Module 1 - Teradata Studio Features Optimize

More information

DB2 SQL Class Outline

DB2 SQL Class Outline DB2 SQL Class Outline The Basics of SQL Introduction Finding Your Current Schema Setting Your Default SCHEMA SELECT * (All Columns) in a Table SELECT Specific Columns in a Table Commas in the Front or

More information

The Top 20 Design Tips

The Top 20 Design Tips The Top 20 Design Tips For MySQL Enterprise Data Architects Ronald Bradford COO PrimeBase Technologies April 2008 Presented Version By: 1.1 Ronald 10.Apr.2008 Bradford 1. Know Your Technology Tools Generics

More information

T-SQL Training: T-SQL for SQL Server for Developers

T-SQL Training: T-SQL for SQL Server for Developers Duration: 3 days T-SQL Training Overview T-SQL for SQL Server for Developers training teaches developers all the Transact-SQL skills they need to develop queries and views, and manipulate data in a SQL

More information

Oracle 1Z0-882 Exam. Volume: 100 Questions. Question No: 1 Consider the table structure shown by this output: Mysql> desc city:

Oracle 1Z0-882 Exam. Volume: 100 Questions. Question No: 1 Consider the table structure shown by this output: Mysql> desc city: Volume: 100 Questions Question No: 1 Consider the table structure shown by this output: Mysql> desc city: 5 rows in set (0.00 sec) You execute this statement: SELECT -,-, city. * FROM city LIMIT 1 What

More information

COMP 430 Intro. to Database Systems

COMP 430 Intro. to Database Systems SELECT name FROM sqlite_master WHERE type='table' COMP 430 Intro. to Database Systems Single-table SQL Get clickers today! Slides use ideas from Chris Ré and Chris Jermaine. Clicker test Have you used

More information

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas

SQL Functionality SQL. Creating Relation Schemas. Creating Relation Schemas SQL SQL Functionality stands for Structured Query Language sometimes pronounced sequel a very-high-level (declarative) language user specifies what is wanted, not how to find it number of standards original

More information

Creating Tables, Defining Constraints. Rose-Hulman Institute of Technology Curt Clifton

Creating Tables, Defining Constraints. Rose-Hulman Institute of Technology Curt Clifton Creating Tables, Defining Constraints Rose-Hulman Institute of Technology Curt Clifton Outline Data Types Creating and Altering Tables Constraints Primary and Foreign Key Constraints Row and Tuple Checks

More information

Introduction to Database Systems CSE 444

Introduction to Database Systems CSE 444 Introduction to Database Systems CSE 444 Lecture 2: SQL Announcements Project 1 & Hw 1 are posted on class website Project 1 (SQL) due in two weeks Homework 1 (E/R models etc) due in three weeks Remember:

More information

SQL Data Definition Language: Create and Change the Database Ray Lockwood

SQL Data Definition Language: Create and Change the Database Ray Lockwood Introductory SQL SQL Data Definition Language: Create and Change the Database Pg 1 SQL Data Definition Language: Create and Change the Database Ray Lockwood Points: DDL statements create and alter the

More information

Querying Data with Transact SQL

Querying Data with Transact SQL Course 20761A: Querying Data with Transact SQL Course details Course Outline Module 1: Introduction to Microsoft SQL Server 2016 This module introduces SQL Server, the versions of SQL Server, including

More information

Announcements. Multi-column Keys. Multi-column Keys. Multi-column Keys (3) Multi-column Keys (2) Introduction to Data Management CSE 414

Announcements. Multi-column Keys. Multi-column Keys. Multi-column Keys (3) Multi-column Keys (2) Introduction to Data Management CSE 414 Introduction to Data Management CSE 414 Lecture 3: More SQL (including most of Ch. 6.1-6.2) Announcements WQ2 will be posted tomorrow and due on Oct. 17, 11pm HW2 will be posted tomorrow and due on Oct.

More information

Introduction to Data Management CSE 344

Introduction to Data Management CSE 344 Introduction to Data Management CSE 344 Lectures 4 and 5: Aggregates in SQL Dan Suciu - CSE 344, Winter 2012 1 Announcements Homework 1 is due tonight! Quiz 1 due Saturday Homework 2 is posted (due next

More information

Operating systems fundamentals - B07

Operating systems fundamentals - B07 Operating systems fundamentals - B07 David Kendall Northumbria University David Kendall (Northumbria University) Operating systems fundamentals - B07 1 / 33 What is SQL? Structured Query Language Used

More information

Constraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2

Constraints. Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers. John Edgar 2 CMPT 354 Constraints Primary Key Foreign Key General table constraints Domain constraints Assertions Triggers John Edgar 2 firstname type balance city customerid lastname accnumber rate branchname phone

More information

2017/11/04 04:02 1/12 Coding Conventions

2017/11/04 04:02 1/12 Coding Conventions 2017/11/04 04:02 1/12 Coding Conventions Coding Conventions SQL Statements (Selects) Use the more readable ANSI-Standard Join clauses (SQL-92 syntax) instead of the old style joins (SQL-89 syntax). The

More information

Principles of Data Management

Principles of Data Management Principles of Data Management Alvin Lin August 2018 - December 2018 Structured Query Language Structured Query Language (SQL) was created at IBM in the 80s: SQL-86 (first standard) SQL-89 SQL-92 (what

More information

Unit 6. Scalar Functions

Unit 6. Scalar Functions Unit 6. Scalar Functions What This Unit Is About This unit provides information on how to use various common scalar functions. What You Should Be Able to Do After completing this unit, you should be able

More information

SQL Structured Query Language Introduction

SQL Structured Query Language Introduction SQL Structured Query Language Introduction Rifat Shahriyar Dept of CSE, BUET Tables In relational database systems data are represented using tables (relations). A query issued against the database also

More information

CSE 530A. Inheritance and Partitioning. Washington University Fall 2013

CSE 530A. Inheritance and Partitioning. Washington University Fall 2013 CSE 530A Inheritance and Partitioning Washington University Fall 2013 Inheritance PostgreSQL provides table inheritance SQL defines type inheritance, PostgreSQL's table inheritance is different A table

More information

Comparative Analysis of the Selected Relational Database Management Systems

Comparative Analysis of the Selected Relational Database Management Systems Comparative Analysis of the Selected Relational Database Management Systems R. Poljak, P. Poščić and D. Jakšić Department of informatics-university of Rijeka/ Rijeka, Croatia rpoljak@student.uniri.hr,

More information

Lecture 2: Introduction to SQL

Lecture 2: Introduction to SQL Lecture 2: Introduction to SQL Lecture 2 Announcements! 1. If you still have Jupyter trouble, let us know! 2. Enroll to Piazza!!! 3. People are looking for groups. Team up! 4. Enrollment should be finalized

More information

Reference: W3School -

Reference: W3School - Language SQL SQL Adv Reference: W3School - http://www.w3schools.com/sql/default.asp http://www.tomjewett.com/dbdesign/dbdesign.php?page=recursive.php SQL Aliases SQL aliases are used to give a table, or

More information

Advanced MySQL Query Tuning

Advanced MySQL Query Tuning Advanced MySQL Query Tuning Alexander Rubin July 21, 2013 About Me My name is Alexander Rubin Working with MySQL for over 10 years Started at MySQL AB, then Sun Microsystems, then Oracle (MySQL Consulting)

More information

Announcements. Multi-column Keys. Multi-column Keys (3) Multi-column Keys. Multi-column Keys (2) Introduction to Data Management CSE 414

Announcements. Multi-column Keys. Multi-column Keys (3) Multi-column Keys. Multi-column Keys (2) Introduction to Data Management CSE 414 Introduction to Data Management CSE 414 Announcements Reminder: first web quiz due Sunday Lecture 3: More SQL (including most of Ch. 6.1-6.2) CSE 414 - Spring 2017 1 CSE 414 - Spring 2017 2 Multi-column

More information

SQL: Data Definition Language

SQL: Data Definition Language SQL: Data Definition Language CSC 343 Winter 2018 MICHAEL LIUT (MICHAEL.LIUT@UTORONTO.CA) DEPARTMENT OF MATHEMATICAL AND COMPUTATIONAL SCIENCES UNIVERSITY OF TORONTO MISSISSAUGA Database Schemas in SQL

More information

Introduction to Data Management CSE 414

Introduction to Data Management CSE 414 Introduction to Data Management CSE 414 Lecture 3: More SQL (including most of Ch. 6.1-6.2) Overload: https://goo.gl/forms/2pfbteexg5l7wdc12 CSE 414 - Fall 2017 1 Announcements WQ2 will be posted tomorrow

More information

618 Index. BIT data type, 108, 109 BIT_LENGTH, 595f BIT VARYING data type, 108 BLOB data type, 108 Boolean data type, 109

618 Index. BIT data type, 108, 109 BIT_LENGTH, 595f BIT VARYING data type, 108 BLOB data type, 108 Boolean data type, 109 Index A abbreviations in field names, 22 in table names, 31 Access. See under Microsoft acronyms in field names, 22 in table names, 31 aggregate functions, 74, 375 377, 416 428. See also AVG; COUNT; COUNT(*);

More information

Ebook : Overview of application development. All code from the application series books listed at:

Ebook : Overview of application development. All code from the application series books listed at: Ebook : Overview of application development. All code from the application series books listed at: http://www.vkinfotek.com with permission. Publishers: VK Publishers Established: 2001 Type of books: Develop

More information

INTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey

INTERMEDIATE SQL GOING BEYOND THE SELECT. Created by Brian Duffey INTERMEDIATE SQL GOING BEYOND THE SELECT Created by Brian Duffey WHO I AM Brian Duffey 3 years consultant at michaels, ross, and cole 9+ years SQL user What have I used SQL for? ROADMAP Introduction 1.

More information

Creating and Managing Tables Schedule: Timing Topic

Creating and Managing Tables Schedule: Timing Topic 9 Creating and Managing Tables Schedule: Timing Topic 30 minutes Lecture 20 minutes Practice 50 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the

More information

MTA Database Administrator Fundamentals Course

MTA Database Administrator Fundamentals Course MTA Database Administrator Fundamentals Course Session 1 Section A: Database Tables Tables Representing Data with Tables SQL Server Management Studio Section B: Database Relationships Flat File Databases

More information

DS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

DS Introduction to SQL Part 1 Single-Table Queries. By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) DS 1300 - Introduction to SQL Part 1 Single-Table Queries By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Overview 1. SQL introduction & schema definitions 2. Basic single-table

More information

Mysql Insert Manual Timestamp Into Datetime Field

Mysql Insert Manual Timestamp Into Datetime Field Mysql Insert Manual Timestamp Into Datetime Field You can set the default value of a DATE, DATETIME or TIMESTAMP field to the For INSERT IGNORE and UPDATE IGNORE, '0000-00-00' is permitted and NULL DEFAULT

More information

Mobile MOUSe MTA DATABASE ADMINISTRATOR FUNDAMENTALS ONLINE COURSE OUTLINE

Mobile MOUSe MTA DATABASE ADMINISTRATOR FUNDAMENTALS ONLINE COURSE OUTLINE Mobile MOUSe MTA DATABASE ADMINISTRATOR FUNDAMENTALS ONLINE COURSE OUTLINE COURSE TITLE MTA DATABASE ADMINISTRATOR FUNDAMENTALS COURSE DURATION 10 Hour(s) of Self-Paced Interactive Training COURSE OVERVIEW

More information

Lecture 3 SQL. Shuigeng Zhou. September 23, 2008 School of Computer Science Fudan University

Lecture 3 SQL. Shuigeng Zhou. September 23, 2008 School of Computer Science Fudan University Lecture 3 SQL Shuigeng Zhou September 23, 2008 School of Computer Science Fudan University Outline Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries Derived Relations Views

More information

Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford)

Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Introduction to SQL Part 1 By Michael Hahsler based on slides for CS145 Introduction to Databases (Stanford) Lecture 2 Lecture Overview 1. SQL introduction & schema definitions 2. Basic single-table queries

More information

Course Topics. Microsoft SQL Server. Dr. Shohreh Ajoudanian. 01 Installing MSSQL Server Data types

Course Topics. Microsoft SQL Server. Dr. Shohreh Ajoudanian. 01 Installing MSSQL Server Data types Dr. Shohreh Ajoudanian Course Topics Microsoft SQL Server 01 Installing MSSQL Server 2008 03 Creating a database 05 Querying Tables with SELECT 07 Using Set Operators 02 Data types 04 Creating a table,

More information

Principles of Database Systems CSE 544. Lecture #2 SQL The Complete Story

Principles of Database Systems CSE 544. Lecture #2 SQL The Complete Story Principles of Database Systems CSE 544 Lecture #2 SQL The Complete Story CSE544 - Spring, 2013 1 Announcements Paper assignment Review was due last night Discussion on Thursday We need to schedule a makeup

More information

Advanced MySQL Query Tuning

Advanced MySQL Query Tuning Advanced MySQL Query Tuning Alexander Rubin August 6, 2014 About Me My name is Alexander Rubin Working with MySQL for over 10 years Started at MySQL AB, then Sun Microsystems, then Oracle (MySQL Consulting)

More information

Chapter 3 Introduction to relational databases and MySQL

Chapter 3 Introduction to relational databases and MySQL Chapter 3 Introduction to relational databases and MySQL Murach's PHP and MySQL, C3 2014, Mike Murach & Associates, Inc. Slide 1 Objectives Applied 1. Use phpmyadmin to review the data and structure of

More information

Data Access 3. Managing Apache Hive. Date of Publish:

Data Access 3. Managing Apache Hive. Date of Publish: 3 Managing Apache Hive Date of Publish: 2018-07-12 http://docs.hortonworks.com Contents ACID operations... 3 Configure partitions for transactions...3 View transactions...3 View transaction locks... 4

More information

SQL Interview Questions

SQL Interview Questions SQL Interview Questions SQL stands for Structured Query Language. It is used as a programming language for querying Relational Database Management Systems. In this tutorial, we shall go through the basic

More information

Lab # 2 Hands-On. DDL Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia

Lab # 2 Hands-On. DDL Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia Lab # 2 Hands-On DDL Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia Part A: Demo by Instructor in Lab a. Data type of MySQL b. CREATE table c. ALTER table (ADD, CHANGE,

More information

IBM DB2 9 Family Fundamentals. Download Full Version :

IBM DB2 9 Family Fundamentals. Download Full Version : IBM 000-730 DB2 9 Family Fundamentals Download Full Version : http://killexams.com/pass4sure/exam-detail/000-730 Answer: D QUESTION: 292 The EMPLOYEE table contains the following information: EMPNO NAME

More information

MySQL Schema Review 101

MySQL Schema Review 101 MySQL Schema Review 101 How and What you should be looking at... Mike Benshoof - Technical Account Manager, Percona Agenda Introduction Key things to consider and review Tools to isolate issues Common

More information

Sun Certified MySQL 5.0 Developer Part II

Sun Certified MySQL 5.0 Developer Part II 310-813 Sun Certified MySQL 5.0 Developer Part II Version 13.3 QUESTION NO: 1 When executing multi-row operations, what should be the first thing you look for to see if anything unexpected happened? A.

More information

Announcements. Outline UNIQUE. (Inner) joins. (Inner) Joins. Database Systems CSE 414. WQ1 is posted to gradebook double check scores

Announcements. Outline UNIQUE. (Inner) joins. (Inner) Joins. Database Systems CSE 414. WQ1 is posted to gradebook double check scores Announcements Database Systems CSE 414 Lectures 4: Joins & Aggregation (Ch. 6.1-6.4) WQ1 is posted to gradebook double check scores WQ2 is out due next Sunday HW1 is due Tuesday (tomorrow), 11pm HW2 is

More information

Polaris SQL Introduction. Michael Fields Central Library Consortium

Polaris SQL Introduction. Michael Fields Central Library Consortium Polaris SQL Introduction Michael Fields Central Library Consortium Topics Covered Connecting to your Polaris SQL server Basic SQL query syntax Frequently used Polaris tables Using your SQL queries inside

More information

MySQL 101. Designing effective schema for InnoDB. Yves Trudeau April 2015

MySQL 101. Designing effective schema for InnoDB. Yves Trudeau April 2015 MySQL 101 Designing effective schema for InnoDB Yves Trudeau April 2015 About myself : Yves Trudeau Principal architect at Percona since 2009 With MySQL then Sun, 2007 to 2009 Focus on MySQL HA and distributed

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe CHAPTER 6 Basic SQL Slide 6-2 Chapter 6 Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries in SQL INSERT, DELETE, and UPDATE Statements in SQL Additional Features

More information

Exam code: Exam name: Database Fundamentals. Version 16.0

Exam code: Exam name: Database Fundamentals. Version 16.0 98-364 Number: 98-364 Passing Score: 800 Time Limit: 120 min File Version: 16.0 Exam code: 98-364 Exam name: Database Fundamentals Version 16.0 98-364 QUESTION 1 You have a table that contains the following

More information

Outline. Introduction to SQL. What happens when you run an SQL query? There are 6 possible clauses in a select statement. Tara Murphy and James Curran

Outline. Introduction to SQL. What happens when you run an SQL query? There are 6 possible clauses in a select statement. Tara Murphy and James Curran Basic SQL queries Filtering Joining tables Grouping 2 Outline Introduction to SQL Tara Murphy and James Curran 1 Basic SQL queries 2 Filtering 27th March, 2008 3 Joining tables 4 Grouping Basic SQL queries

More information

SQL Server Administration Class 4 of 4. Activant Prophet 21. Basic Data Manipulation

SQL Server Administration Class 4 of 4. Activant Prophet 21. Basic Data Manipulation SQL Server Administration Class 4 of 4 Activant Prophet 21 Basic Data Manipulation This class is designed for Beginner SQL/Prophet21 users who are responsible for SQL Administration as it relates to Prophet

More information

1) Introduction to SQL

1) Introduction to SQL 1) Introduction to SQL a) Database language enables users to: i) Create the database and relation structure; ii) Perform insertion, modification and deletion of data from the relationship; and iii) Perform

More information

We re going to start with two.csv files that need to be imported to SQL Lite housing2000.csv and housing2013.csv

We re going to start with two.csv files that need to be imported to SQL Lite housing2000.csv and housing2013.csv Basic SQL joining exercise using SQL Lite Using Census data on housing units, by place Created by @MaryJoWebster January 2017 The goal of this exercise is to introduce how joining tables works in SQL.

More information

ColumnStore Indexes UNIQUE and NOT DULL

ColumnStore Indexes UNIQUE and NOT DULL Agenda ColumnStore Indexes About me The Basics Key Characteristics DEMO SQL Server 2014 ColumnStore indexes DEMO Best Practices Data Types Restrictions SQL Server 2016+ ColumnStore indexes Gareth Swanepoel

More information

SQL OVERVIEW. CS121: Relational Databases Fall 2017 Lecture 4

SQL OVERVIEW. CS121: Relational Databases Fall 2017 Lecture 4 SQL OVERVIEW CS121: Relational Databases Fall 2017 Lecture 4 SQL 2 SQL = Structured Query Language Original language was SEQUEL IBM s System R project (early 1970 s) Structured English Query Language Caught

More information

Simple Quesries in SQL & Table Creation and Data Manipulation

Simple Quesries in SQL & Table Creation and Data Manipulation Simple Quesries in SQL & Table Creation and Data Manipulation Based on CBSE Curriculum Class -11 By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region Neha Tyagi, PGT CS II Shift Jaipur Introduction

More information

Introduction to relational databases and MySQL

Introduction to relational databases and MySQL Chapter 3 Introduction to relational databases and MySQL A products table Columns 2017, Mike Murach & Associates, Inc. C3, Slide 1 2017, Mike Murach & Associates, Inc. C3, Slide 4 Objectives Applied 1.

More information

Introduction to Computer Science and Business

Introduction to Computer Science and Business Introduction to Computer Science and Business This is the second portion of the Database Design and Programming with SQL course. In this portion, students implement their database design by creating a

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Querying Data with Transact-SQL General Description This course is designed to introduce students to Transact-SQL. It is designed in such a way that the first three days can be taught as a course to students

More information

Relational Database Management Systems for Epidemiologists: SQL Part I

Relational Database Management Systems for Epidemiologists: SQL Part I Relational Database Management Systems for Epidemiologists: SQL Part I Outline SQL Basics Retrieving Data from a Table Operators and Functions What is SQL? SQL is the standard programming language to create,

More information

Information Systems for Engineers Fall Data Definition with SQL

Information Systems for Engineers Fall Data Definition with SQL Ghislain Fourny Information Systems for Engineers Fall 2018 3. Data Definition with SQL Rare Book and Manuscript Library, Columbia University. What does data look like? Relations 2 Reminder: relation 0

More information

Lab 4: Tables and Constraints

Lab 4: Tables and Constraints Lab : Tables and Constraints Objective You have had a brief introduction to tables and how to create them, but we want to have a more in-depth look at what goes into creating a table, making good choices

More information

HOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL

HOW TO CREATE AND MAINTAIN DATABASES AND TABLES. By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL HOW TO CREATE AND MAINTAIN DATABASES AND TABLES By S. Sabraz Nawaz Senior Lecturer in MIT FMC, SEUSL What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate

More information

20761B: QUERYING DATA WITH TRANSACT-SQL

20761B: QUERYING DATA WITH TRANSACT-SQL ABOUT THIS COURSE This 5 day course is designed to introduce students to Transact-SQL. It is designed in such a way that the first three days can be taught as a course to students requiring the knowledge

More information

SQL Data Definition and Data Manipulation Languages (DDL and DML)

SQL Data Definition and Data Manipulation Languages (DDL and DML) .. Cal Poly CPE/CSC 365: Introduction to Database Systems Alexander Dekhtyar.. SQL Data Definition and Data Manipulation Languages (DDL and DML) Note: This handout instroduces both the ANSI SQL synatax

More information

Documentation Accessibility. Access to Oracle Support. Supported Browsers

Documentation Accessibility. Access to Oracle Support. Supported Browsers Oracle Cloud Known Issues for Oracle Business Intelligence Cloud Service E37404-12 March 2018 Known Issues Learn about the issues you may encounter when using Oracle Business Intelligence Cloud Service

More information

MySQL User Conference and Expo 2010 Optimizing Stored Routines

MySQL User Conference and Expo 2010 Optimizing Stored Routines MySQL User Conference and Expo 2010 Optimizing Stored Routines 1 Welcome, thanks for attending! Roland Bouman; Leiden, Netherlands Ex MySQL AB, Sun Microsystems Web and BI Developer Co-author of Pentaho

More information

GridDB Advanced Edition SQL reference

GridDB Advanced Edition SQL reference GMA022C1 GridDB Advanced Edition SQL reference Toshiba Solutions Corporation 2016 All Rights Reserved. Introduction This manual describes how to write a SQL command in the GridDB Advanced Edition. Please

More information

Data Types in MySQL CSCU9Q5. MySQL. Data Types. Consequences of Data Types. Common Data Types. Storage size Character String Date and Time.

Data Types in MySQL CSCU9Q5. MySQL. Data Types. Consequences of Data Types. Common Data Types. Storage size Character String Date and Time. - Database P&A Data Types in MySQL MySQL Data Types Data types define the way data in a field can be manipulated For example, you can multiply two numbers but not two strings We have seen data types mentioned

More information

[0569] p 0318 garbage

[0569] p 0318 garbage A Pointer is a variable which contains the address of another variable. Declaration syntax: Pointer_type *pointer_name; This declaration will create a pointer of the pointer_name which will point to the

More information

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014 The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014 MySQL Setup, using console Data types Overview Creating users, databases and tables SQL queries INSERT, SELECT, DELETE WHERE, ORDER

More information

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 4. Basic SQL. Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Basic SQL Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4 Outline SQL Data Definition and Data Types Specifying Constraints in SQL Basic Retrieval Queries

More information

1. Given the name of a movie studio, find the net worth of its president.

1. Given the name of a movie studio, find the net worth of its president. 1. Given the name of a movie studio, find the net worth of its president. CREATE FUNCTION GetNetWorth( studio VARCHAR(30) ) RETURNS DECIMAL(9,3) DECLARE worth DECIMAL(9,3); SELECT networth INTO worth FROM

More information

Sara Lee Corporation ("SLE") Reverse Split, Name/Symbol Change, Cash Distribution, and Spin-off Ex-Distribution Date: June 29, 2012

Sara Lee Corporation (SLE) Reverse Split, Name/Symbol Change, Cash Distribution, and Spin-off Ex-Distribution Date: June 29, 2012 CBOE Research Circular #RS12-320 DATE: June 26, 2012 TO: Permit Holders FROM: Scott Speer RE: Sara Lee Corporation ("SLE") Reverse Split, Name/Symbol Change, Cash Distribution, and Spin-off Ex-Distribution

More information

File Structures and Indexing

File Structures and Indexing File Structures and Indexing CPS352: Database Systems Simon Miner Gordon College Last Revised: 10/11/12 Agenda Check-in Database File Structures Indexing Database Design Tips Check-in Database File Structures

More information

MySQL Workshop. Scott D. Anderson

MySQL Workshop. Scott D. Anderson MySQL Workshop Scott D. Anderson Workshop Plan Part 1: Simple Queries Part 2: Creating a database: creating a table inserting, updating and deleting data handling NULL values datatypes Part 3: Joining

More information

Practical MySQL indexing guidelines

Practical MySQL indexing guidelines Practical MySQL indexing guidelines Percona Live October 24th-25th, 2011 London, UK Stéphane Combaudon stephane.combaudon@dailymotion.com Agenda Introduction Bad indexes & performance drops Guidelines

More information

Querying Data with Transact-SQL

Querying Data with Transact-SQL Querying Data with Transact-SQL Course 20761C 5 Days Instructor-led, Hands on Course Information The main purpose of the course is to give students a good understanding of the Transact- SQL language which

More information

SQL. Often times, in order for us to build the most functional website we can, we depend on a database to store information.

SQL. Often times, in order for us to build the most functional website we can, we depend on a database to store information. Often times, in order for us to build the most functional website we can, we depend on a database to store information. If you ve ever used Microsoft Excel or Google Spreadsheets (among others), odds are

More information

Sql Server Check If Global Temporary Table Exists

Sql Server Check If Global Temporary Table Exists Sql Server Check If Global Temporary Table Exists I am trying to create a temp table from the a select statement so that I can get the schema information from the temp I have yet to see a valid justification

More information