Premium Essay

Unit 9 Sql

In:

Submitted By ruffduck1
Words 689
Pages 3
Create Database, Create Table, Alter Table, Insert, Update, and Delete When Constraints May Be Violated
Unit 9
Alexander Diaz
Kaplan University
August 12, 2014

Unit 9
-- Q1. Use tempDB -- Create a table called MyNewTable with three columns (rowID smallint, createdDate datetime, name varchar with a length of 30)
[pic]

-- Q2. Use tempDB -- Create a script that checks to see if MyNewTable Exists, drop it if it does.
Recreate the query in Question 1 so that table does not allow an insert where the createdDate is less than the current datetime --- Insert a row into MyNewTable using the current datetime value--- If your Insert completed successfully something is wrong with your previous statements. If it failed? Explain why and how you might change the create table --- In order to fix the problem, assuming you always want to insert every row using the current date time value. Hint -- Search for -- "adding a second to a date field SQL"
[pic]
I believe using the smalldatetime option in order to use the ‘ss’ for the two digits to represent the ranging value from 00 to 59. Also using an alias for the table name in order for the query to proceed without errors.

-- Q3. In the script above, Explain exactly why you cannot update col1 for the final two statements in the list.
Each column in a table must have a specific data type and usually a maximum size that controls what data can be inserted or updated and whether a column may contain NULL values. You can’t add a non-numeric string to an INT column. It is also possible to further control what data you can add by defining check constraints. For example, you may want to restrict the values of a column to a particular range of values.
-- Q4. Using Alter Table statements. Add a new Column to MyNewTable (see q1 above) column name =primaryID (as an INT)
-- Add a Primary Key Constraint to

Similar Documents

Premium Essay

Lesson 5

...‘000843’; 3. How do you form a compound condition? By connecting two or more simple conditions with the AND, OR, and NOT operators 9. How do you sort data? You can sort data by using the ORDER BY operator. 12. What are the SQL aggregate functions? The SQL aggregate function are functions used to calculate sums, averages, counts, maximum values, and minimum values. 14. What is a subquery? When a query is inside of another query the inner query is the subquery. 15. How do you group data in an SQL query? You can group SQL query data by using the GROUP BY clause on a particular object. 16. When grouping data in a query, how do you restrict the output to only those groups satisfying some condition? By using the HAVING clause a query can be written to display the groups that are included Also complete the following Exercises using the Premier Products database on page 132: 3. List the names of customers with credit limits of $10,000 or more. 5. List the number and name of each customer represented by sales rep 35 or sales rep 65. 8 List the part number, part description, and on-hand value (units on hand * unit price) of each part in item class SG.(On-hand value is really units on hand * cost, but there is no COST col- umn in the PART table.) Assign the name ON_HAND_VALUE to the computed column. 9. List the part number, part description, and on-hand value for each part whose on-hand value is at least $7,500. Assign the name ON_HAND_VALUE...

Words: 327 - Pages: 2

Premium Essay

Unit 6 Research Assignment 1

...Concepts Unit 6 Research Assignment 1: Explore the latest ANSI and ISO Standard True/False 23-Jul-2016 Tim Church Daigre ANSI- The American National Standards Institute (ANSI) oversees the creation, promulgation and use of thousands of norms and guidelines that directly impact businesses in nearly every sector: from acoustical devices to construction equipment, from dairy and livestock production to energy distribution, and many more. ANSI is also actively engaged in accreditation - assessing the competence of organizations determining conformance to standards. To enhance both the global competitiveness of U.S. business and the U.S. quality of life by promoting and facilitating voluntary consensus standards and conformity assessment systems, and safeguarding their integrity. ISO- International Organization for Standardization (ISO) is an independent, non-governmental international organization with a membership of 163 national standards bodies. Through its members, it brings together experts to share knowledge and develop voluntary, consensus-based, market relevant International Standards that support innovation and provide solutions to global challenges. Part II- The latest SQL standard was adopted in July 2003 and is often called SQL:2003. One part of the SQL standard, Part 14, SQL/XML (ISO/IEC 9075-14) was revised in 2006 and is often referenced as "SQL/XML:2006". ANSI/ISO/IEC 9075:2003, "Database Language SQL", Parts 1 ("SQL/Framework"), 2 ("SQL/Foundation")...

Words: 278 - Pages: 2

Premium Essay

Unit 6 Assignment 1 Questions

...Unit 6 Assignment 1: Homework Learning Objectives and Outcomes Name the main events in the development of SQL statements. Run SELECT queries with wild cards, DISTINCT key word, calculations, sorting and aliasing. Run queries with the WHERE clause to filter the result sets. Use the Aggregate functions COUNT, AVG, SUM, MIN, and MAX. Assignment Requirements Answer the true-or-false questions on the next page by filling out the answer sheet. Required Resources Textbook Submission Requirements Submit your completed answer sheet to your instructor at the beginning of Unit 7. Unit 6 True/False Questions Indicate whether the following statements are true or false on the student answer sheet. 1) SQL is the programming language used to manipulate data and data objects in a relational database management system. 2) SQL is a procedural language. 3) A declarative language is a language in which you tell the computer what to do not how. 4) DML, or Data Manipulation Language, contains all the commands for selecting and modifying data. 5) DDL, or Data Definition Language, contains all the commands for selecting and modifying data. 6) The * in SELECT * clause of an SQL statement is a wildcard for returning all columns in a table. 7) The DISTINCT keyword in a SELECT statement returns only unique rows. 8) The FROM keyword is used in a SELECT clause to determine which columns are included in the query. 9) An alias in SQL is a substitute...

Words: 363 - Pages: 2

Premium Essay

Dbm 449 Laboratory Procedures Ilab 6 Answers

...com I. OBJECTIVES 1. Understand and become familiar with the SQL Analytical Extensions. 2. Learn to create, use, and maintain materialized views, and their functional equivalents. 3. Effectively apply Advanced Aggregate SQL Operations, such as GROUP BY ROLLUP to solve business intelligence questions and analytical processing problems. II. PARTS LIST 1. EDUPE-VT Omnymbus Virtual Machine Environment (https://devry.edupe.net:9090/) and/or: 2. MySQL (dev.mysql.com/downloads) III. PROCEDURE Scenario and Summary For the lab this week, we are going to look at how the ROLLUP and CUBE extensions available in SQL can be used to create query result sets that have more than one dimension to them. Both of these extensions are used in conjunction with the GROUP BY clause and allow for a much broader look at the data. To record your work for this lab use the lab report found at the end of this document. As in your previous labs, you will need to copy/paste your SQL statements and results into this document. Upon completion and prior to the due date, submit this document to the appropriate Dropbox. iLAB STEPS STEP 1: Setting Up For this lab you will be using a different user and set of tables than you have used so far for other labs. To set up your instance you will need to do the following. The first thing you will do for this lab is to run the following SQL Script. Begin by creating the DBM449Lab6 Schema, and creating any user accounts and...

Words: 3288 - Pages: 14

Premium Essay

Dbm 449 Laboratory Procedures Ilab 6 Answers

...com I. OBJECTIVES 1. Understand and become familiar with the SQL Analytical Extensions. 2. Learn to create, use, and maintain materialized views, and their functional equivalents. 3. Effectively apply Advanced Aggregate SQL Operations, such as GROUP BY ROLLUP to solve business intelligence questions and analytical processing problems. II. PARTS LIST 1. EDUPE-VT Omnymbus Virtual Machine Environment (https://devry.edupe.net:9090/) and/or: 2. MySQL (dev.mysql.com/downloads) III. PROCEDURE Scenario and Summary For the lab this week, we are going to look at how the ROLLUP and CUBE extensions available in SQL can be used to create query result sets that have more than one dimension to them. Both of these extensions are used in conjunction with the GROUP BY clause and allow for a much broader look at the data. To record your work for this lab use the lab report found at the end of this document. As in your previous labs, you will need to copy/paste your SQL statements and results into this document. Upon completion and prior to the due date, submit this document to the appropriate Dropbox. iLAB STEPS STEP 1: Setting Up For this lab you will be using a different user and set of tables than you have used so far for other labs. To set up your instance you will need to do the following. The first thing you will do for this lab is to run the following SQL Script. Begin by creating the DBM449Lab6 Schema, and creating any user accounts and...

Words: 3288 - Pages: 14

Premium Essay

Asignment

...Oracle® Database Concepts 10g Release 2 (10.2) B14220-02 October 2005 Oracle Database Concepts, 10g Release 2 (10.2) B14220-02 Copyright © 1993, 2005, Oracle. All rights reserved. Primary Author: Michele Cyran Contributing Author: Paul Lane, JP Polk Contributor: Omar Alonso, Penny Avril, Hermann Baer, Sandeepan Banerjee, Mark Bauer, Bill Bridge, Sandra Cheevers, Carol Colrain, Vira Goorah, Mike Hartstein, John Haydu, Wei Hu, Ramkumar Krishnan, Vasudha Krishnaswamy, Bill Lee, Bryn Llewellyn, Rich Long, Diana Lorentz, Paul Manning, Valarie Moore, Mughees Minhas, Gopal Mulagund, Muthu Olagappan, Jennifer Polk, Kathy Rich, John Russell, Viv Schupmann, Bob Thome, Randy Urbano, Michael Verheij, Ron Weiss, Steve Wertheimer The Programs (which include both the software and documentation) contain proprietary information; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent, and other intellectual and industrial property laws. Reverse engineering, disassembly, or decompilation of the Programs, except to the extent required to obtain interoperability with other independently created software or as specified by law, is prohibited. The information contained in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. This document is not warranted to be error-free. Except as may be expressly permitted in your license agreement...

Words: 199783 - Pages: 800

Premium Essay

Cscc 640

...executes a dynamic SQL statement or an anonymous PL/SQL block. ____ 2. The %TYPE feature allows you to anchor variable declarations to a column in a table. ____ 3. COMMIT and ROLLBACK end the active autonomous transaction but do not exit the autonomous routine. ____ 4. The only required sections of a PL/SQL block are BEGIN and END. ____ 5. The EXCEPTION handling section is an optional section in a PL/SQL block. ____ 6. The keyword DEFAULT can be used in place of the := symbol to assign initial values to the variables within the declaration statement. ____ 7. Declaring a table of records variable in a package specification allows it to persist for a user session. ____ 8. Implicit cursors are declared automatically for all INSERT, UPDATE, and DELETE statements issued within a PL/SQL block. ____ 9. You can process multiple rows of data from a database by creating explicit cursors. ____ 10. With an implicit cursor, Oracle closes the SQL cursor automatically after executing its associated SQL statement. As a result, %ISOPEN always yields FALSE. ____ 11. The basic loop uses the LOOP and END LOOP markers to begin and end the loop code. ____ 12. Dynamic SQL lets you write schema-management procedures that can be centralized in one schema, and can be called from other schemas and operate on the objects in those schemas. ____ 13. In PL/SQL, if a SELECT ... INTO statement returns no rows, Oracle does not return an error. ____ 14. In PL/SQL, a SELECT ......

Words: 1344 - Pages: 6

Free Essay

Performance Analysis of Substitution Cipher Based Cryptographic Algorithm

...CURRICULUM VITAE EGUNSOLA Olubola Kehinde 16, Adeolu Egunsola Street Off Jibowu Estate Road U-Turn Bus Stop Abule-Egba Lagos. PERSONAL PORTFOLIO Date of Birth 17th August 1972 Place of Birth Lagos State State of Origin Ogun State Nationality Nigerian L.G.A Abeokuta South Sex Male Marital Status Married Number of Child. Three Children, 8yrs, 5yrs, and 3yrs old E-Mail egunsola_olubola @yahoo.com Phone Number 08035855769 07086566947 Permanent Address 10, Ogere Road, Iperu-Remo, Ogun State. EDUCATIONAL BACKGROUND Institution Certificate Date Federal University of Technology M.Tech 2010-2013 Yola, Adamawa State Operations Research option(Computer Simulation) Olabisi Onabanjo University Ago Iwoye B.Sc (Ed) 1997-2000 (Formerly Ogun State University) Computer Science Federal College of Education Osiele N.C.E 1994-1996 Abeokuta Ogun State Computer Science/PSC Egbado College Ilaro ...

Words: 1309 - Pages: 6

Premium Essay

Sql Lab 4

...MET CS 669 Database Design and Implementation for Business SQL Lab 4 Instructions: Procedural SQL Objective  The objective of this lab is to teach you how to develop and use basic stored  procedures and triggers the procedural language of your chosen DBMS.  Prerequisites  Before attempting this lab, it is best to read the textbook and lecture material  covering the objectives listed above. While this lab shows you how to create and use  these constructs in SQL, the lab does not explain in full the theory behind the  constructs, as does the lecture and textbook.    The second section in this lab builds on Lab 3. It is best to complete Lab 3 first before  completing the second section in this lab.  Required Software  The examples in this lab will execute in modern versions of Oracle and Microsoft SQL  Server as is. Note that the first section in this lab has syntax specific to each DBMS,  and you will need to complete the version for the DBMS you are using. If you are  using a different RDBMS, you may need to modify the SQL for successful execution.  Saving Your Data  If you choose to perform portions of the assignment in different sittings, it is  important to commit your data at the end of each session. This way, you will be sure  to make permanent any data changes you have made in your curent session, so that  you can resume working without issue in your next session. To do so, simply issue  this command:    COMMIT; Data changes in one session will only be visible only in that session...

Words: 6758 - Pages: 28

Premium Essay

Wk 3 Lab

... * Conduct a manual Cross-site Scripting (XSS) attack against sample vulnerable web applications * Perform SQL injection attacks against sample vulnerable web applications with e-commerce data entry fields * Mitigate known web application and web server vulnerabilities with security countermeasures to eliminate risk from compromise and exploitation Overview This Lab will demonstrate a Cross-site Scripting (XSS) exploit and an SQL Injection attack on the test bed web application and web server using the Damn Vulnerable Web App (DVWA) loaded on an Apache Web Server on “TargetUbuntu01” Linux VM server. They will first identify the IP target host, identify known vulnerabilities and exploits, and then attack the web application and web server using XSS and an SQL Injection to exploit the web application using a web browser and some simple command strings. Assignment Requirements Watch the Demo Lab in Learning Space Unit 5 and then answer questions 1-10 below. Lab Assessment Questions & Answers 1. Why is it critical to perform a penetration test on a web application prior to production implementation? 2. What is a cross-site scripting attack? Explain in your own words. 3. What is a reflective cross-site scripting attack? 4. What common method of obfuscation is used in most real world SQL attacks? 5. Which web application attack is more prone to extract privacy data...

Words: 1054 - Pages: 5

Premium Essay

Mr. 893723974

...Introduction to SQL LEARNING OBJECTIVES After studying this chapter, you should be able to: ■ Concisely define each of the following key terms: relational DBMS (RDBMS), catalog, schema, data definition language (DDL), data manipulation language (DML), data control language (DCL), scalar aggregate, vector aggregate, base table, virtual table, dynamic view, and materialized view. ■ ■ ■ ■ ■ Visit www.pearsonhighered.com/ hoffer to view the accompanying video for this chapter. Interpret the history and role of SQL in database development. Define a database using the SQL data definition language. Write single-table queries using SQL commands. Establish referential integrity using SQL. Discuss the SQL:1999 and SQL:2008 standards. INTRODUCTION Pronounced “S-Q-L” by some and “sequel” by others, SQL has become the de facto standard language for creating and querying relational databases. (Can the next standard be the sequel to SQL?) The primary purpose of this chapter is to introduce SQL, the most common language for relational systems. It has been accepted as a U.S. standard by the American National Standards Institute (ANSI) and is a Federal Information Processing Standard (FIPS). It is also an international standard recognized by the International Organization for Standardization (ISO). ANSI has accredited the International Committee for Information Technology Standards (INCITS) as a standards development organization; INCITS is working on the next version of the SQL standard...

Words: 22483 - Pages: 90

Premium Essay

Cloud Database Management System

...technology ............................................................................................................ 2 Challenges of Implementation: ................................................................................................. 9 Reference: ............................................................................................................................... 10 General business case Thanks to the successful management, the business of the company expands very fast. However, the database management system cannot withstand the quickly and greatly increased work load, the break-down frequency increases, which make the decision-making efficiency and customer experience drop. The company tries to turn around this bad trend and poses two solutions: one is to update the present DBMS including hardware, software and human resource; the other one is to make use of SQL Azure from Microsoft to set up cloud environment and transfer the DBMS there. After cost analysis, we find that to reach the same efficiency standard, the cost of first solution is 9 times of the second solution, and the second solution has merits such as capability, flexibility and elasticity, so we suggest implementing the second solution: Cloud DBMS, SQL Azure. Introduction and problems We are an express company in North America. We transport the parcels for customers. We have good performance and with the blooming online shopping, our business...

Words: 3594 - Pages: 15

Premium Essay

IT560 Unit 4 Assignment

...IT560 Unit 4 Assignment Syed M Amin Kaplan University IT560 Unit 4 Assignment In the last report, it was highlighted that an ERP based system can not only facilitate our employees in making better decisions and giving more productivity but an off-the-shelf ERP solution can also lower the overall cost of doing business by eliminating redundant systems and processes. Also, off-the-shelf ERP software is the easiest to implement and carries lower risks associated with it because of feedback from companies that have already used the same software before. Cost and time are key factors during the selection phase of an Enterprise Resource Planning solution. Customization to prewritten ERP packages is expensive, especially when the software needs to be upgraded. The answer to this is the employment of off-the-shelf ERP software. A...

Words: 941 - Pages: 4

Premium Essay

Report

...Project Submitted to the Al Musanna College of Technology in partial fulfillment of the requirements for the award of the Degree of Higher Diploma in Internet and E-Security Submitted by: (1) 2782011- Abdullah ALJaradi - “Leader” (2) 2782239 - Auf ALMujaini Project Supervisor : Mrs.Divyajyothi M G Al Musanna College of Technology Declaration We hereby declare that the project entitled “Banking Security System “ submitted for the Higher Diploma in Internet and E-Security is our original work and this project work has not formed the basis for the award of any degree. Name of the students | Signature | Abdullah Aljaradi | | Auf Almujini | | Date of submission:- | Place:- | Acknowledgment We would like to express our deep thanks and appreciation to all who have supported us by providing a good and encouraging atmosphere to successfully complete our Higher Diploma project . Thanks to Allah for granting us with the necessary patience to finish our project successfully. we hope it will be successful. Our profound thanks to our family for granting us a suitable and comfortable home environment in order to work on our project. Our sincere appreciation is extended to the technician Mr.Nasser Ali for his continuous guidance and support throughout the course of this project. Thank you dear sir for your concerned guidance and good instructions. Many thanks to Mrs.Divyajyothi for...

Words: 1256 - Pages: 6

Premium Essay

Paper

...recoverable. Also, the database must be flexible. Meaning, if there is something new that needs to be implemented, the database must be able to adapt to change. Database Architecture The database architecture is a set of parameters and processes that determine how data is stored and accessible by other individuals and databases. Database architecture focuses on the development, implementation, design, and maintenance of program. Design architecture helps develop software to better benefit the future user. There are numerous types of database that are created such as Oracle, SQL Server, and Microsoft Access. The SQL server is very important when it comes to database architects. Database architects use varies languages to create databases. Therefore, the languages are requested using the structured query language (SQL). IBM designed the SQL in 1974. It was first introduced by Oracle in 1979. SQL is very favorable among information technology specialist. Workplace Databases The database that my company uses is the Microsoft format. All salesman use Microsoft formatted handhelds to conduct orders and deliveries for each sales account, clock in and out daily, scan back room and shelf inventory, as well as a GPS tracking device to monitor employee daily activity. The handhelds contain a history of data from past years and adjusts the data for the present orders based on market growth and consistent product activity. The data is classified as structured because all the information...

Words: 485 - Pages: 2