SQL stands for Structured Query Language. SQL is the lingua franca
|
|
- Juliet Spencer
- 5 years ago
- Views:
Transcription
1 Chapter 3: Database for $100, Please In This Chapter Understanding some basic database concepts Taking a quick look at SQL Creating tables Selecting data Joining data Updating and deleting data SQL stands for Structured Query Language. SQL is the lingua franca (that s not a type of pasta it s a type of tongue) of relational databases. SQL is the standard language used for creating and accessing relational databases and is the foundation of database processing in Java. Note that Java doesn t provide any implementation of SQL itself. Instead, Java provides JDBC Java DataBase Connectivity that lets you formulate SQL statements, send them off to a database server, and process the results. But in order to use JDBC, you need to know some basic concepts of SQL databases and a least enough SQL to formulate some sensible SQL statements. This chapter won t make you a database guru or a SQL expert. SQL is a complicated language that is the subject of many of its own books, including SQL For Dummies by Allen G. Taylor (Wiley). This chapter covers just enough SQL to get you going with JDBC. Also, this chapter doesn t cover JDBC. I decided to defer that until the next chapter so that if you already know SQL, you can skip this chapter altogether. What Is a Relational Database? The term relational database is one of the most used and abused buzzwords in all of computerdom. A relational database can be A database in which data is stored in tables. Relationships can be established between tables based on common information. For example, a table of customers and a table of invoices might both contain a customer number column. This column can serve as the basis for a relationship between the tables.
2 704 What Is SQL, and How Do You Pronounce It? A database that is accessed via Structured Query Language (SQL). SQL was originally invented by IBM back in the 1970s to provide a practical way to access data stored in relational databases. Any database system developed since about 1980, with the exception of a few cutting-edge Object Oriented Databases. Marketers quickly figured out that the way to sell database programs was to advertise them as relational. Thus, just about every database program ever made has claimed to be relational, whether it really is or not. From a Java programmer s perspective, the second definition is the only one that matters. If you can use SQL to access the database, the database is relational. What Is SQL, and How Do You Pronounce It? SQL is a query language, which means it is designed to extract, organize, and update information in relational databases. Way back in the 1970s, when SQL was invented (SQL is old enough to be Java s grandfather), SQL was supposed to be an English-like query language that could be used by untrained end users to access and update relational database data without the need for programming. Of course, that didn t happen. SQL is nothing like English. It s way too complicated and esoteric for untrained end users to learn, but it has become the overwhelming favorite among programmers. Ever since you first saw the letters SQL, you ve probably been wondering how to pronounce it. If not, humor me. Two schools of thought exist on this subject: Spell out the letters: Es Que El. Pronounce it like the word sequel. Either one does the job, but sequel makes you sound less like a database rookie. SQL Statements Unlike Java, SQL is not object oriented. Remember, SQL was invented during the Nixon administration. However, like Java, SQL does use statements to get work done. Table 3-1 lists the SQL statements you use most often.
3 Database for $100, Please Creating a SQL Database 705 Table 3-1 SQL Statement Data Manipulation select insert delete update Data Definition create alter drop use Description Common SQL Statements Retrieves data from one or more tables. This is the statement you use most often. Inserts one or more rows into a table. Deletes one or more rows from a table. Updates existing rows in a table. Creates tables and other database objects. Changes the definitions of a table or other database object. Deletes a table or other database object. Used in scripts to indicate what database subsequent statements apply to. Note that unlike Java, statements in SQL are not case sensitive. Thus, you can write select, Select, or SELECT. You could even write select for kicks, if you want. Creating a SQL Database Before you can store data in a relational database, you must create the database. You don t normally do that from a Java program. Instead, you do it by writing a script file that contains the Create statements necessary to create the table, and then run the script through the database server s administration program. (Note that some database servers also let you define databases interactively. However, the script approach is preferred because you often need to delete and re-create a database while testing your applications.) The scripts shown in this section (and in the rest of this chapter) are for version 4.1 of MySQL. MySQL is a free SQL database server you can download from MySQL includes a program called the MySQL Command Line Client that lets you enter SQL commands from a prompt and immediately see the results. Book VIII Chapter 3 Script statements end with semicolons. That s about the only thing SQL scripts have in common with Java. Be aware, however, that the semicolon isn t required when you use SQL statements in a Java program. The semicolon is required only when you use SQL statements in a script or interactively from the MySQL Command Line Client program. I don t have room in this book to go into a complete tutorial on writing scripts that create SQL databases. So instead, I present a sample script,
4 706 Creating a SQL Database Listing 3-1, that creates a database named movies that s used in the rest of this chapter and in the next, and walk you through its most important lines. LISTING 3-1: A DATABASE CREATION SCRIPT drop database movies; 1 create database movies; 2 use movies; 3 create table movie ( 4 id int not null auto_increment, 5 title varchar(50), 6 year int, 7 price decimal(8,2), 8 primary key(id) 9 ); 12 values ( It s a Wonderful Life, 1946, 14.95); values ( The Great Race, 1965, 12.95); values ( Young Frankenstein, 1974, 16.95); values ( The Return of the Pink Panther, 1975, 11.95); values ( Star Wars, 1977, 17.95); values ( The Princess Bride, 1987, 16.95); values ( Glory, 1989, 14.95); values ( Apollo 13, 1995, 19.95); values ( The Game, 1997, 14.95); values ( The Lord of the Rings: The Fellowship of the Ring, 2001, 19.95); The following paragraphs describe the important lines of this script: 1 It s common for a script that creates a database to begin with a drop database statement to delete any existing database with the same name. During testing, it s common to delete and re-create the database, so you want to include this statement in your scripts. 2 This statement creates a new database named movies. 3 The use statement indicates that the script statements that follow applies to the newly created movies database. 4 This create table statement creates a table named movie with columns named id, title, year, and price. This statement also specifies that the primary key for the table is the id column.
5 Database for $100, Please Querying a Database The id column s data type is int, which corresponds to Java s int type. This column also specifies not null, which means that it must have a value for every row, and it specifies auto increment, which means that the database server itself provides values for this column. Each time a new row is added to the table, the value for the id column is automatically incremented. 6 The title column s data type is varchar, which is like a Java String. 7 The year column s data type is int. 8 The price column s data type is decimal. Java doesn t have a decimal type, so the values from this column are converted to double. 9 The create table statement specifies that the id column is the table s primary key. A primary key is a column (or a combination of columns) that contains a unique value for each row in a table. Every table should have a primary key. 12 The insert statements add data to the database. Each of these ten statements adds a row to the movie table. The syntax of the insert statement is weird, because you first list all the columns that you want to insert data for, and then you list the actual data. For example, each of the insert statements inserts data for three columns: title, year, and price. The first insert statement (the one in line 12) inserts the values It s a Wonderful Life, 1946, and To run this script in MySQL, start the MySQL Command Line Client from the Start menu. Then, use a source command that names the script. For example: mysql> source c:\data\create.sql Querying a Database As the name Structured Query Language suggests, queries are what SQL is all about. A query is an operation that is performed against one or more SQL tables that extracts data from the tables and creates a result set containing the selected rows and columns. A crucial point to understand is that the result set is itself a table consisting of rows and columns. When you query a database from a Java program, the result set is returned to the program in an object created from the ResultSet class. This class has methods that let you extract the data from each column of each row in the result set. Book VIII Chapter 3 Using your basic select To query a database, you use the select statement. In the select statement, you list the table or tables from which you want to retrieve the data, the specific table columns you want to retrieve (you might not be interested
6 708 Querying a Database in everything that s in the table), and other clauses that indicate which specific rows to retrieve, what order to present the rows in, and so on. Here s a simple select statement that lists all the movies in the movie table: select title, year from movie order by year; When you take this statement apart piece by piece, you get: select title, year names the columns you want included in the query result. from movie names the table you want the rows retrieved from. order by year indicates that the result is sorted into sequence by the year column so the oldest movie appears first. In other words, this select statement retrieves the title and date for all the rows in the movie table and sorts them into year sequence. You can run this query by typing it directly into the MySQL Command Line Client. Here s what you get: mysql> select title, year from movie order by year; title year It s a Wonderful Life 1946 The Great Race 1965 Young Frankenstein 1974 The Return of the Pink Panther 1975 Star Wars 1977 The Princess Bride 1987 Glory 1989 Apollo The Game 1997 The Lord of the Rings: The Fellowship of the Ring rows in set (0.09 sec) As you can see, the Command Line Client displays the rows returned by the select statement. This can be very handy when you re planning the select statements your program needs or when you re testing a program that updates a table and you want to make sure the updates are made correctly. If you want the query to retrieve all the columns in each row, you can use an asterisk instead of naming the individual columns: select * from movie order by year; Use an asterisk in this manner in a program is not a good idea, however, because the columns that make up the table might change. If you use an asterisk, your program can t deal with changes to the table s structure.
7 Database for $100, Please Querying a Database 709 Both examples so far include an order by clause. In a SQL database, the rows stored in a table are not assumed to be in any particular sequence. As a result, if you want to display the results of a query in sequence, you must include an order by in the select statement. Narrowing down the query Suppose you want to find information about one particular video title. To select certain rows from a table, use the where clause in a select statement. For example: mysql> select title, year from movie -> where year <= > order by year; title year It s a Wonderful Life 1946 The Great Race 1965 Young Frankenstein 1974 The Return of the Pink Panther 1975 Star Wars rows in set (0.00 sec) Here, the select statement selects all the rows in which the year column is less than or equal to The results are ordered by the year column. Excluding rows Perhaps you want to retrieve all rows except those that match certain criteria. For example, here s a query that ignores movies made in the 1970s (which is probably a good idea): mysql> select title, year from movie -> where year < 1970 or year > > order by year; title year It s a Wonderful Life 1946 The Great Race 1965 The Princess Bride 1987 Glory 1989 Apollo The Game 1997 The Lord of the Rings: The Fellowship of the Ring rows in set (0.41 sec) Book VIII Chapter 3 Singleton selects When you want to retrieve information for a specific row, mention the primary key column in the where clause, like this:
8 710 Querying a Database mysql> select title, year from movie where id = 7; title year Glory row in set (0.49 sec) Here, the where clause selects the row whose id column equals 7. This type of select statement is called a singleton select because it retrieves only one row. Singleton selects are commonly used in Java programs to allow users to access or update a specific database row. Sounds like Suppose you want to retrieve information about a movie, but you can t quite remember the name. You know it has the word princess in it though. One of the more interesting variations of the where clause is to throw in the word like, which lets you search rows using wildcards. Here s an example in which the percent sign (%) is a wildcard character: mysql> select title, year from movie -> where title like %princess% ; title year The Princess Bride row in set (0.00 sec) Column functions What if you want a count of the total number of movies in the movie table? Or a count of the number of movies that were made before 1970? To do that, you use a column function. SQL s column functions let you make calculations on columns. You can calculate the sum, average, largest or smallest value, or count the number of values for an entire column. Table 3-2 summarizes these functions. Note that these functions operate on the values returned in a result set, which isn t necessarily the entire table. Table 3-2 Function sum(column-name) avg(column-name) min(column-name) max(column-name) Description Column Functions Adds up the values in the column. Calculates the average value for the column. Null values are not figured in the calculation. Determines the lowest value in the column. Determines the highest value in the column.
9 Database for $100, Please Querying a Database 711 Function Description count(column-name) Counts the number of rows that have data values for the column. countdistinct Counts the number of distinct values for the column. (column-name) count(*) Counts the number of rows in the result set. To use one of these functions, specify the function rather than a column name in a select statement. For example, the following select statement calculates the number of rows in the table and the year of the oldest movie: mysql> select count(*), min(year) from movie; count(*) min(year) row in set (0.00 sec) As you can see, ten movies are in the table, and the oldest was made in If the select statement includes a where clause, only the rows that match the criteria are included in the calculation. For example, this statement finds out how many movies in the table were made before 1970: mysql> select count(*) from movie where year < 1970; count(*) row in set (0.00 sec) The result is only two. Selecting from more than one table In the real world, most select statements retrieve data from two or more tables. Suppose you want a list of all the movies you ve currently loaned out to friends. To do that, you have to create another table in your database that lists your friends names and the ids of any movie they ve borrowed. Here s a create table statement that creates just such a table: Book VIII Chapter 3 create table friend ( lastname varchar(50), firstname varchar(50), movieid int ); Now load it up with some data:
10 712 Querying a Database insert into friend (lastname, firstname, movieid) values ( Haskell, Eddie, 3); insert into friend (lastname, firstname, movieid) values ( Haskell, Eddie, 5); insert into friend (lastname, firstname, movieid) values ( Cleaver, Wally, 9); insert into friend (lastname, firstname, movieid) values ( Mondello, Lumpy, 2); insert into friend (lastname, firstname, movieid) values ( Cleaver, Wally, 3); With that out of the way, you can get to the business of using both the friend and movie tables in a single select statement. All you have to do is list both tables in the from clause, and then provide a condition in the where clause that correlates the tables. For example: mysql> select lastname, firstname, title -> from movie, friend -> where movie.id = friend.movieid; lastname firstname title Haskell Eddie Young Frankenstein Haskell Eddie Star Wars Cleaver Wally The Game Mondello Lumpy The Great Race Cleaver Wally Young Frankenstein rows in set (0.00 sec) Here, you can see which movies have been lent out and who has them. Notice that the id and movieid columns in the where clause are qualified with the name of the table the column belongs to. Here s a select statement that lists all the movies Eddie Haskell has borrowed: mysql> select title from movie, friend -> where movie.id = friend.movieid -> and lastname = Haskell ; title Young Frankenstein Star Wars rows in set (0.00 sec) That rat has two of your best movies! Notice in this example that you can refer to the friend table in the where clause even though you re not actually retrieving any of its columns. However, you must still mention both tables in the from clause.
11 Database for $100, Please Updating and Deleting Rows 713 Eliminating duplicates If you want to know just the names of everyone who has a movie checked out, you can do a simple select from the friend table: mysql> select lastname, firstname from friend; lastname firstname Haskell Eddie Haskell Eddie Cleaver Wally Mondello Lumpy Cleaver Wally 5 rows in set (0.00 sec) However, this result set has a problem: Eddie Haskel and Wally Cleaver are listed twice. Wouldn t it be nice if you could eliminate the duplicate rows? Your wish is granted in the next paragraph. You can eliminate duplicate rows by adding the distinct keyword in the select statement: mysql> select distinct lastname, firstname from friend; lastname firstname Haskell Eddie Cleaver Wally Mondello Lumpy 3 rows in set (0.07 sec) Notice that no duplicates appear; each distinct name appears only once in the result set. Updating and Deleting Rows You ve already seen how to create databases, insert rows, and retrieve result sets. All that remains now is updating and deleting data in a table. For that, you use the update and delete statements, as described in the following sections. I explain the delete statement first, because it has a simpler syntax. Book VIII Chapter 3 The delete statement The basic syntax of the delete statement is: delete from table-name where condition;
12 714 Updating and Deleting Rows For example, here s a statement that deletes the movie whose id is 10: mysql> delete from movie where id = 10; Query OK, 1 row affected (0.44 sec) Notice that the Command Line Client shows that this statement affected one line. You can confirm that the movie was deleted by following up with a select statement: mysql> select * from movie; id title year price It s a Wonderful Life The Great Race Young Frankenstein The Return of the Pink Panther Star Wars The Princess Bride Glory Apollo The Game rows in set (0.00 sec) As you can see, movie 10 is gone. If the where clause selects more than one row, all the selected rows are deleted. For example mysql> delete from friend where lastname = Haskell ; Query OK, 2 rows affected (0.45 sec) A quick query of the friend table shows that both records for Eddie Haskell are deleted: mysql> select * from friend; lastname firstname movieid Cleaver Wally 9 Mondello Lumpy 2 Cleaver Wally rows in set (0.00 sec) If you don t include a where clause, the entire table is deleted. For example, this statement deletes all the rows in the movie table: mysql> delete from movie; Query OK, 9 rows affected (0.44 sec) A quick select of the movie table confirms that it is now empty:
13 Database for $100, Please Updating and Deleting Rows 715 mysql> select * from movie; Empty set (0.00 sec) Fortunately, you can now just run the create.sql script again to create the table. The update statement The update statement selects one or more rows from a table, and then modifies the value of one or more columns in the selected rows. Its syntax is this: update table-name set expressions... where condition; The set expressions resemble Java assignment statements. For example, here s a statement that changes the price of movie 8 to 18.95: mysql> update movie set price = where id = 8; Query OK, 1 row affected (0.44 sec) Rows matched: 1 Changed: 1 Warnings: 0 You can use a quick select statement to verify that the price was changed: mysql> select id, price from movie; id price rows in set (0.01 sec) Book VIII Chapter 3 To update more than one column, use commas to separate the expressions. For example, here s a statement that changes Eddie Haskell s name in the friend table: mysql> update friend set lastname = Bully, -> firstname = Big -> where lastname = Haskell ; Query OK, 2 rows affected (0.46 sec) Rows matched: 2 Changed: 2 Warnings: 0
14 716 Updating and Deleting Rows Again, a quick select shows that the rows are properly updated: mysql> select firstname, lastname from friend; firstname lastname Big Bully Big Bully Wally Cleaver Lumpy Mondello Wally Cleaver rows in set (0.00 sec) One final trick with the update statement you should know about is that the set expressions can include calculations. For example, the following statement increases the price of all the movies by 10 percent: mysql> update movie set price = price * 1.1; Query OK, 10 rows affected (0.46 sec) Rows matched: 10 Changed: 10 Warnings: 0 Here s a select statement to verify that this update worked: mysql> select id, price from movie; id price rows in set (0.01 sec)
JDBC Java Database Connectivity is a Java feature that lets you connect
Chapter 4: Using JDBC to Connect to a Database In This Chapter Configuring JDBC drivers Creating a connection Executing SQL statements Retrieving result data Updating and deleting data JDBC Java Database
More informationSQL 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 informationSTOP DROWNING IN DATA. START MAKING SENSE! An Introduction To SQLite Databases. (Data for this tutorial at
STOP DROWNING IN DATA. START MAKING SENSE! Or An Introduction To SQLite Databases (Data for this tutorial at www.peteraldhous.com/data) You may have previously used spreadsheets to organize and analyze
More informationT-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 informationSQL 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 informationSlicing and Dicing Data in CF and SQL: Part 1
Slicing and Dicing Data in CF and SQL: Part 1 Charlie Arehart Founder/CTO Systemanage carehart@systemanage.com SysteManage: Agenda Slicing and Dicing Data in Many Ways Handling Distinct Column Values Manipulating
More informationThis 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 informationSQL. Dean Williamson, Ph.D. Assistant Vice President Institutional Research, Effectiveness, Analysis & Accreditation Prairie View A&M University
SQL Dean Williamson, Ph.D. Assistant Vice President Institutional Research, Effectiveness, Analysis & Accreditation Prairie View A&M University SQL 1965: Maron & Levien propose Relational Data File 1968:
More informationProvider: MySQLAB Web page:
Provider: MySQLAB Web page: www.mysql.com Installation of MySQL. Installation of MySQL. Download the mysql-3.3.5-win.zip and mysql++-.7.--win3-vc++.zip files from the mysql.com site. Unzip mysql-3.3.5-win.zip
More informationWhat is SQL? Toolkit for this guide. Learning SQL Using phpmyadmin
http://www.php-editors.com/articles/sql_phpmyadmin.php 1 of 8 Members Login User Name: Article: Learning SQL using phpmyadmin Password: Remember Me? register now! Main Menu PHP Tools PHP Help Request PHP
More informationDatabases (MariaDB/MySQL) CS401, Fall 2015
Databases (MariaDB/MySQL) CS401, Fall 2015 Database Basics Relational Database Method of structuring data as tables associated to each other by shared attributes. Tables (kind of like a Java class) have
More informationMySQL: 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 informationTUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL
TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL We have spent the first part of the course learning Excel: importing files, cleaning, sorting, filtering, pivot tables and exporting
More informationAccess - Introduction to Queries
Access - Introduction to Queries Part of managing a database involves asking questions about the data. A query is an Access object that you can use to ask the question(s). The answer is contained in the
More informationSQL - Tables. SQL - Create a SQL Table. SQL Create Table Query:
SQL - Tables Data is stored inside SQL tables which are contained within SQL databases. A single database can house hundreds of tables, each playing its own unique role in th+e database schema. While database
More informationHKTA TANG HIN MEMORIAL SECONDARY SCHOOL SECONDARY 3 COMPUTER LITERACY. Name: ( ) Class: Date: Databases and Microsoft Access
Databases and Microsoft Access Introduction to Databases A well-designed database enables huge data storage and efficient data retrieval. Term Database Table Record Field Primary key Index Meaning A organized
More information2) SQL includes a data definition language, a data manipulation language, and SQL/Persistent stored modules. Answer: TRUE Diff: 2 Page Ref: 36
Database Processing, 12e (Kroenke/Auer) Chapter 2: Introduction to Structured Query Language (SQL) 1) SQL stands for Standard Query Language. Diff: 1 Page Ref: 32 2) SQL includes a data definition language,
More informationUnit 27 Web Server Scripting Extended Diploma in ICT
Unit 27 Web Server Scripting Extended Diploma in ICT Dynamic Web pages Having created a few web pages with dynamic content (Browser information) we now need to create dynamic pages with information from
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationtablename ORDER BY column ASC tablename ORDER BY column DESC sortingorder, } The WHERE and ORDER BY clauses can be combined in one
} The result of a query can be sorted in ascending or descending order using the optional ORDER BY clause. The simplest form of an ORDER BY clause is SELECT columnname1, columnname2, FROM tablename ORDER
More informationCSCI 1100L: Topics in Computing Lab Lab 07: Microsoft Access (Databases) Part I: Movie review database.
CSCI 1100L: Topics in Computing Lab Lab 07: Microsoft Access (Databases) Purpose: The purpose of this lab is to introduce you to the basics of creating a database and writing SQL (Structured Query Language)
More informationUsing Parameter Queries
[Revised and Updated 21 August 2018] A useful feature of the query is that it can be saved and used again and again, whenever we want to ask the same question. The result we see (the recordset) always
More informationTest Bank for Database Processing Fundamentals Design and Implementation 13th Edition by Kroenke
Test Bank for Database Processing Fundamentals Design and Implementation 13th Edition by Kroenke Link full download: https://testbankservice.com/download/test-bank-fordatabase-processing-fundamentals-design-and-implementation-13th-edition-bykroenke
More informationIntroduction to Databases and SQL
Introduction to Databases and SQL Files vs Databases In the last chapter you learned how your PHP scripts can use external files to store and retrieve data. Although files do a great job in many circumstances,
More informationChapter 9: MySQL for Server-Side Data Storage
Chapter 9: MySQL for Server-Side Data Storage General Notes on the Slides for This Chapter In many slides you will see webbook as a database name. That was the orginal name of our database. For this second
More informationSQL for MySQL A Beginner s Tutorial
SQL for MySQL A Beginner s Tutorial Djoni Darmawikarta SQL for MySQL: A Beginner s Tutorial Copyright 2014 Brainy Software Inc. First Edition: June 2014 All rights reserved. No part of this book may be
More informationCPS221 Lecture: Relational Database Querying and Updating
CPS221 Lecture: Relational Database Querying and Updating last revised 8/5/10 Objectives: 1. To introduce the SQL select statement 2. To introduce the SQL insert, update, and delete statements Materials:
More informationOracle Exam 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer Version: 7.0 [ Total Questions: 100 ]
s@lm@n Oracle Exam 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer Version: 7.0 [ Total Questions: 100 ] Oracle 1z0-882 : Practice Test Question No : 1 Consider the statements: Mysql> drop function
More informationCOSC 2P91. Bringing it all together... Week 4b. Brock University. Brock University (Week 4b) Bringing it all together... 1 / 22
COSC 2P91 Bringing it all together... Week 4b Brock University Brock University (Week 4b) Bringing it all together... 1 / 22 A note on practicality and program design... Writing a single, monolithic source
More informationChapter 4: SQL Basics
Chapter 4: SQL Basics ALT_ENTER Will Maximize Window in Command Line Mode o SQL Basics Structured Query Language Used to create & extract data in a database environment SQL history Began as SEQUEL o Structured
More informationCPS221 Lecture: Relational Database Querying and Updating
CPS221 Lecture: Relational Database Querying and Updating Objectives: last revised 10/29/14 1. To introduce the SQL select statement 2. To introduce the SQL insert, update, and delete statements Materials:
More informationFull file at
David Kroenke's Database Processing: Fundamentals, Design and Implementation (10 th Edition) CHAPTER TWO INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) True-False Questions 1. SQL stands for Standard
More informationJarek Szlichta
Jarek Szlichta http://data.science.uoit.ca/ SQL is a standard language for accessing and manipulating databases What is SQL? SQL stands for Structured Query Language SQL lets you gain access and control
More informationUAccess ANALYTICS Next Steps: Working with Bins, Groups, and Calculated Items: Combining Data Your Way
UAccess ANALYTICS Next Steps: Working with Bins, Groups, and Calculated Items: Arizona Board of Regents, 2014 THE UNIVERSITY OF ARIZONA created 02.07.2014 v.1.00 For information and permission to use our
More informationLearning Objectives. Description. Your AU Expert(s) Trent Earley Behlen Mfg. Co. Shane Wemhoff Behlen Mfg. Co.
PL17257 JavaScript and PLM: Empowering the User Trent Earley Behlen Mfg. Co. Shane Wemhoff Behlen Mfg. Co. Learning Objectives Using items and setting data in a Workspace Setting Data in Related Workspaces
More informationMicrosoft Access XP (2002) - Advanced Queries
Microsoft Access XP (2002) - Advanced Queries Group/Summary Operations Change Join Properties Not Equal Query Parameter Queries Working with Text IIF Queries Expression Builder Backing up Tables Action
More informationCOMP519: Web Programming Autumn 2015
COMP519: Web Programming Autumn 2015 In the next lectures you will learn What is SQL How to access mysql database How to create a basic mysql database How to use some basic queries How to use PHP and mysql
More informationExcel Basics: Working with Spreadsheets
Excel Basics: Working with Spreadsheets E 890 / 1 Unravel the Mysteries of Cells, Rows, Ranges, Formulas and More Spreadsheets are all about numbers: they help us keep track of figures and make calculations.
More informationPolaris 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 informationGEO 425: SPRING 2012 LAB 9: Introduction to Postgresql and SQL
GEO 425: SPRING 2012 LAB 9: Introduction to Postgresql and SQL Objectives: This lab is designed to introduce you to Postgresql, a powerful database management system. This exercise covers: 1. Starting
More informationToday Learning outcomes LO2
2015 2016 Phil Smith Today Learning outcomes LO2 On successful completion of this unit you will: 1. Be able to design and implement relational database systems. 2. Requirements. 3. User Interface. I am
More informationRelational Database Development
Instructor s Relational Database Development Views, Indexes & Security Relational Database Development 152-156 Views, Indexes & Security Quick Links & Text References View Description Pages 182 183 187
More informationChameleon Metadata s Data Science Basics Tutorial Series. DSB-2: Information Gain (IG) By Eric Thornton,
Chameleon Metadata s Data Science Basics Tutorial Series Data Science Basics Syllabus for DSB-2 (DSB-2-Infographic-1) Download PDF version here: DSB-2-Information-Gain-V10.pdf DSB-2: Information Gain (IG)
More informationXP: Backup Your Important Files for Safety
XP: Backup Your Important Files for Safety X 380 / 1 Protect Your Personal Files Against Accidental Loss with XP s Backup Wizard Your computer contains a great many important files, but when it comes to
More informationSTIDistrict Query (Basic)
STIDistrict Query (Basic) Creating a Basic Query To create a basic query in the Query Builder, open the STIDistrict workstation and click on Utilities Query Builder. When the program opens, database objects
More informationConsistency The DBMS must ensure the database will always be in a consistent state. Whenever data is modified, the database will change from one
Data Management We start our studies of Computer Science with the problem of data storage and organization. Nowadays, we are inundated by data from all over. To name a few data sources in our lives, we
More informationGetting Information from a Table
ch02.fm Page 45 Wednesday, April 14, 1999 2:44 PM Chapter 2 Getting Information from a Table This chapter explains the basic technique of getting the information you want from a table when you do not want
More information1. Managing Information in Table
1. Managing Information in Table Spreadsheets are great for making lists (such as phone lists, client lists). The researchers discovered that not only was list management the number one spreadsheet activity,
More informationGetting Started with Amicus Document Assembly
Getting Started with Amicus Document Assembly How great would it be to automatically create legal documents with just a few mouse clicks? We re going to show you how to do exactly that and how to get started
More informationCreating the Data Layer
Creating the Data Layer When interacting with any system it is always useful if it remembers all the settings and changes between visits. For example, Facebook has the details of your login and any conversations
More informationWHAT IS A DATABASE? There are at least six commonly known database types: flat, hierarchical, network, relational, dimensional, and object.
1 WHAT IS A DATABASE? A database is any organized collection of data that fulfills some purpose. As weather researchers, you will often have to access and evaluate large amounts of weather data, and this
More informationTUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL
TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL We have spent the first part of the course learning Excel: importing files, cleaning, sorting, filtering, pivot tables and exporting
More informationCSC Web Programming. Introduction to SQL
CSC 242 - Web Programming Introduction to SQL SQL Statements Data Definition Language CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE Data Query Language SELECT SQL statements end with
More informationViews in SQL Server 2000
Views in SQL Server 2000 By: Kristofer Gafvert Copyright 2003 Kristofer Gafvert 1 Copyright Information Copyright 2003 Kristofer Gafvert (kgafvert@ilopia.com). No part of this publication may be transmitted,
More informationFull file at Chapter 2: An Introduction to SQL
Chapter 2: An Introduction to SQL TRUE/FALSE 1. Tables are called relations. ANS: T PTS: 1 REF: 26 2. Each column in a table of a relational database should have a unique name. ANS: T PTS: 1 REF: 29 3.
More informationOracle SQL. murach s. and PL/SQL TRAINING & REFERENCE. (Chapter 2)
TRAINING & REFERENCE murach s Oracle SQL and PL/SQL (Chapter 2) works with all versions through 11g Thanks for reviewing this chapter from Murach s Oracle SQL and PL/SQL. To see the expanded table of contents
More informationuser specifies what is wanted, not how to find it
SQL 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 ANSI SQL updated
More informationCIS 45, The Introduction. What is a database? What is data? What is information?
CIS 45, The Introduction I have traveled the length and breadth of this country and talked with the best people, and I can assure you that data processing is a fad that won t last out the year. The editor
More informationDataCove Tutorial: How to Perform a Search
Contents Introduction Searching: A Simple Example Searching: Date Sent Searches Searching: Sender/Receiver Searches Searching: Text Searches Searching: Multiple Search Fields Searching: Advanced Features
More informationCS 327E Lecture 2. Shirley Cohen. January 27, 2016
CS 327E Lecture 2 Shirley Cohen January 27, 2016 Agenda Announcements Homework for today Reading Quiz Concept Questions Homework for next time Announcements Lecture slides and notes will be posted on the
More informationc r e at i N g yo u r F i r S t d ata b a S e a N d ta b l e
1 Creating Your First Database and Table SQL is more than just a means for extracting knowledge from data. It s also a language for defining the structures that hold data so we can organize relationships
More informationLesson 13 Transcript: User-Defined Functions
Lesson 13 Transcript: User-Defined Functions Slide 1: Cover Welcome to Lesson 13 of DB2 ON CAMPUS LECTURE SERIES. Today, we are going to talk about User-defined Functions. My name is Raul Chong, and I'm
More informationMysql Tutorial Show Table Like Name Not >>>CLICK HERE<<<
Mysql Tutorial Show Table Like Name Not SHOW TABLES LIKE '%shop%' And the command above is not working as Table name and next SHOW CREATE TABLEcommand user889349 Apr 18. If you do not want to see entire
More informationLABORATORY. 16 Databases OBJECTIVE REFERENCES. Write simple SQL queries using the Simple SQL app.
Dmitriy Shironosov/ShutterStock, Inc. Databases 171 LABORATORY 16 Databases OBJECTIVE Write simple SQL queries using the Simple SQL app. REFERENCES Software needed: 1) Simple SQL app from the Lab Manual
More informationModule Five: Lists in Excel
Page 5.1 Module Five: Lists in Excel Welcome to the fifth lesson in the PRC s Excel Spreadsheets Course 1. This lesson introduces you to some basic database concepts. Excel uses the term list when referring
More informationTaskbar: Working with Several Windows at Once
Taskbar: Working with Several Windows at Once Your Best Friend at the Bottom of the Screen How to Make the Most of Your Taskbar The taskbar is the wide bar that stretches across the bottom of your screen,
More informationDatabase Management Systems by Hanh Pham GOALS
PROJECT Note # 02: Database Management Systems by Hanh Pham GOALS Most databases in the world are SQL-based DBMS. Using data and managing DBMS efficiently and effectively can help companies save a lot
More informationVARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.
Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer
More informationInstructor: Craig Duckett. Lecture 02: Thursday, March 29 th, 2018 SQL Basics and SELECT, FROM, WHERE
Instructor: Craig Duckett Lecture 02: Thursday, March 29 th, 2018 SQL Basics and SELECT, FROM, WHERE 1 Assignment 1 is due LECTURE 5, Tuesday, April 10 th, 2018 in StudentTracker by MIDNIGHT MID-TERM EXAM
More informationThe attendee will get a deep dive into all the DDL changes needed in order to exploit DB2 V10 Temporal tables as well as the limitations.
The attendee will get a deep dive into all the DDL changes needed in order to exploit DB2 V10 Temporal tables as well as the limitations. A case study scenario using a live DB2 V10 system will be used
More informationAccess Intermediate
Access 2013 - Intermediate 103-134 Advanced Queries Quick Links Overview Pages AC124 AC125 Selecting Fields Pages AC125 AC128 AC129 AC131 AC238 Sorting Results Pages AC131 AC136 Specifying Criteria Pages
More informationCS211 Lecture: Database Querying and Updating
CS211 Lecture: Database Querying and Updating last revised 9/30/2004 Objectives: 1. To introduce the relational algebra. 2. To introduce the SQL select statement 3. To introduce the SQL insert, update,
More informationLutheran High North Technology The Finder
Lutheran High North Technology shanarussell@lutheranhighnorth.org www.lutheranhighnorth.org/technology The Finder Your Mac s filing system is called the finder. In this document, we will explore different
More informationEE221 Databases Practicals Manual
EE221 Databases Practicals Manual Lab 1 An Introduction to SQL Lab 2 Database Creation and Querying using SQL Assignment Data Analysis, Database Design, Implementation and Relation Normalisation School
More informationchapter 2 G ETTING I NFORMATION FROM A TABLE
chapter 2 Chapter G ETTING I NFORMATION FROM A TABLE This chapter explains the basic technique for getting the information you want from a table when you do not want to make any changes to the data and
More informationFIT 100 More Microsoft Access and Relational Databases Creating Views with SQL
FIT 100 More Microsoft Access and Relational Databases Creating Views with SQL Creating Views with SQL... 1 1. Query Construction in SQL View:... 2 2. Use the QBE:... 5 3. Practice (use the QBE):... 6
More informationMIS2502: Data Analytics SQL Getting Information Out of a Database. Jing Gong
MIS2502: Data Analytics SQL Getting Information Out of a Database Jing Gong gong@temple.edu http://community.mis.temple.edu/gong The relational database Core of Online Transaction Processing (OLTP) A series
More informationLies, Damned Lies, Statistics and SQL
Lies, Damned Lies, Statistics and SQL by Peter Lavin December 17, 2003 Introduction When I read about the Developer Shed December Giveaway Contest in the most recent newsletter a thought occurred to me.
More informationDatabase 2: Slicing and Dicing Data in CF and SQL
Database 2: Slicing and Dicing Data in CF and SQL Charlie Arehart Founder/CTO Systemanage carehart@systemanage.com SysteManage: Agenda Slicing and Dicing Data in Many Ways Handling Distinct Column Values
More informationINFSCI 2710 Database Management Solution to Final Exam
Dr. Stefan Brass May 8, 2000 School of Information Sciences University of Pittsburgh INFSCI 2710 Database Management Solution to Final Exam Statistics The average points reached (out of 42) were 32 (77%),
More informationLesson 1: Creating and formatting an Answers analysis
Lesson 1: Creating and formatting an Answers analysis Answers is the ad-hoc query environment in the OBIEE suite. It is in Answers that you create and format analyses to help analyze business results.
More informationCOMP283-Lecture 6 Applied Database Management
Applied Database Management Introduction Database Administration More Optimisation Maintaining Data Integrity Improving Performance 1 DB Administration: Full-text index Full Text Index Index large text
More informationCGS 3066: Spring 2017 SQL Reference
CGS 3066: Spring 2017 SQL Reference Can also be used as a study guide. Only covers topics discussed in class. This is by no means a complete guide to SQL. Database accounts are being set up for all students
More informationSQL (and MySQL) Useful things I have learnt, borrowed and stolen
SQL (and MySQL) Useful things I have learnt, borrowed and stolen MySQL truncates data MySQL truncates data CREATE TABLE pets ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, type CHAR(3) NOT NULL, PRIMARY KEY
More informationCOPYRIGHT Wavextend B.V. All rights reserved. Calculation Framework user guide, Basic configuration for version
DATA MANIPULATION FRAMEWORK USER GUIDE Basic configuration for version 2011 COPYRIGHT Information in this document, including URL and other Internet Web site references, is subject to change without notice.
More informationCHAPTER4 CONSTRAINTS
CHAPTER4 CONSTRAINTS LEARNING OBJECTIVES After completing this chapter, you should be able to do the following: Explain the purpose of constraints in a table Distinguish among PRIMARY KEY, FOREIGN KEY,
More informationUniversity of Wisconsin System SFS Business Process RPT Basic PeopleSoft Query
Contents PeopleSoft Query Overview... 1 Process Detail... 2 I. Running the Query... 2 II. Query Actions... 5 III. Planning a New Query... 5 IV. How to Find Out Which Record(s) to Use... 5 V. Building a
More informationSQL CHEAT SHEET. created by Tomi Mester
SQL CHEAT SHEET created by Tomi Mester I originally created this cheat sheet for my SQL course and workshop participants.* But I have decided to open-source it and make it available for everyone who wants
More informationUsing the Set Operators. Copyright 2006, Oracle. All rights reserved.
Using the Set Operators Objectives After completing this lesson, you should be able to do the following: Describe set operators Use a set operator to combine multiple queries into a single query Control
More informationAccess Intermediate
Access 2010 - Intermediate 103-134 Advanced Queries Quick Links Overview Pages AC116 AC117 Selecting Fields Pages AC118 AC119 AC122 Sorting Results Pages AC125 AC126 Specifying Criteria Pages AC132 AC134
More informationIntroduction to Databases. MySQL Syntax Guide: Day 1
Introduction to Databases Question What type of database type does Shodor use? Answers A relational database What DBMS does Shodor use? MySQL MySQL Syntax Guide: Day 1 SQL MySQL Syntax Results Building
More informationCopyright 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 informationOVERVIEW OF RELATIONAL DATABASES: KEYS
OVERVIEW OF RELATIONAL DATABASES: KEYS Keys (typically called ID s in the Sierra Database) come in two varieties, and they define the relationship between tables. Primary Key Foreign Key OVERVIEW OF DATABASE
More information1.7 Limit of a Function
1.7 Limit of a Function We will discuss the following in this section: 1. Limit Notation 2. Finding a it numerically 3. Right and Left Hand Limits 4. Infinite Limits Consider the following graph Notation:
More informationDraft. Students Table. FName LName StudentID College Year. Justin Ennen Science Senior. Dan Bass Management Junior
Chapter 6 Introduction to SQL 6.1 What is a SQL? When would I use it? SQL stands for Structured Query Language. It is a language used mainly for talking to database servers. It s main feature divisions
More informationITEC 101 LAB 9 USING A DATABASE: Tables and Queries
ITEC 101 LAB 9 USING A DATABASE: Tables and Queries In the last lab, we saw how a spreadsheet can be useful for organized storage of information. Some kinds of information, however, have more structure
More information12B. Laboratory. Databases. Objective. References. Write simple SQL queries using the Simple SQL applet.
Laboratory Databases 12B Objective Write simple SQL queries using the Simple SQL applet. References Software needed: 1) A web browser (Internet Explorer or Netscape) 2) Applet from the CD-ROM: a) Simple
More informationSQL 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 informationDatabase &.NET Basics: Take what you know about SQL and apply that to SOQL, SOSL, and DML in Apex.
Database &.NET Basics: Take what you know about SQL and apply that to SOQL, SOSL, and DML in Apex. Unit 1: Moving from SQL to SOQL SQL & SOQL Similar but Not the Same: The first thing to know is that although
More informationExcel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller
Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing
More information