unit 5 microsoft sql server and mysql. key concepts dbms variations sql server features sql server...

19
Unit 5 Unit 5 Microsoft SQL Server Microsoft SQL Server and MySQL and MySQL

Upload: horace-fletcher

Post on 04-Jan-2016

271 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Unit 5Unit 5

Microsoft SQL Server Microsoft SQL Server and MySQLand MySQL

Page 2: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Key ConceptsKey Concepts• DBMS variations• SQL Server features• SQL Server Management Studio• MySQL features• Scripts• Queries• Database creation

Page 3: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Management StudioManagement StudioThe Object Explorer shows SQL Server 2005 objects and the folders that are used to contain and organize those objects

The Summary tabbed window displays the objects within the object selected in the Object Explorer window

The System Databases folder contains database objects for the databases automatically created by SQL Server 2005

The Databases folder is selected in the Object Explorer window, so the Summary window shows the contents of Databases

The Art_Course_Database datbase object holds the database named Art_Course_Database

Page 4: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Create DatabaseCreate Database

Click New Database to create a new database

Right-click Databases to display the shortcut menu

Page 5: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Create Database (cont'd)Create Database (cont'd)

Click the OK button to create the new database

Type the new database name here

Page 6: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Create Database (cont'd)Create Database (cont'd)

The WPC database object is displayed in the Summary window showing the folder structure that will contain the database objects

The WPC database object in the Object Explorer expanded to show the folder structure that will be used to contain the database objects

Page 7: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

ScriptsScripts

This is the Microsoft Notepad text editor—the file name is DBC-e03-MSSQL-WPC-Create-Tables.sql

The SQL keyword Name is enclosed in brackets as [Name]

The lines that start with /* arecomments—any text betweenthe /* and the */ characters on aline is a comment and ignoredby the DBMS when it runs the SQL

Page 8: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Script ExecutionScript Execution

You have to specify which database is being used when the script is run—select WPC from the drop down list before executing the script

Click the Execute button in the SQL Editor toolbar to run the script

The tabbed script window with the open script displayed—to close this window after the script is run click the X symbol to the right of this tab

Page 9: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Script ResultsScript Results

The objects representing the tables created by the script are shown in the expanded Tables folder—dbo stands for database owner

Messages are shown here—either that the commands were successful or appropriate error messages

Page 10: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Query WindowQuery Window

Click the New Query button in the Standard toolbar to open the query window and display the MySQL Editor toolbar

Select the database that you want to query by clicking the database name to select the database

The selected (active) database name appears in the SQL Editor toolbar

Type your SQL query into this tabbed window

Page 11: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Sample QuerySample Query

The tabbed Results window—you can adjust window boundaries and column widths using standard Windows drag-and-drop techniques

The SQL query—the asterisk after .sql on the window tab means the text has been changed but not saved

Page 12: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Launching Query BrowserLaunching Query Browser

Type the root user’s password here, then click the OK button

Page 13: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Query BrowserQuery Browser

The SQL query text box in the MySQL Query Browser Query Toolbar—type SQL queries in this area

The ResultSet window—the results of a query are displayed here

The Schemata pane—the default schema can be selected from the available database schemas

Page 14: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Create Database (Schema)Create Database (Schema)

Click Create New Schema to create a new database

Right-click anywhere in the Schemata pane to display the shortcut menu

Page 15: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

New Schema DialogNew Schema Dialog

Click the OK button to create the new database

Type the new database (“schema”) name here

Page 16: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Creating a ScriptCreating a Script

This is the Microsoft Notepad text editor—the file name is DBC-e03-MySQL-WPC-Create-Tables.sql

Page 17: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Open ScriptOpen Script

The Script 1 tabbed window with the open script displayed—to close this window after the script is run click the X symbol on this tab

Click the Execute button to run the script

After the script is run, expand the WPC schema object to see the tables created by the script

Page 18: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Scripted Query ResultsScripted Query Results

This is the MySQL Query Browser Query Toolbar—enter your SQL statement into this text box and then click the Execute button to the right to run the query

Query results are shown in the Resultset window—you can use standard Windows drag and drop techniques to change the column widths to adjust the results display

Page 19: Unit 5 Microsoft SQL Server and MySQL. Key Concepts DBMS variations SQL Server features SQL Server Management Studio MySQL features Scripts Queries Database

Additional ResultsAdditional Results

Use the File | New Resultset Tab command to open an additional tabbed Results window—you can have multiple Results and Script windows open at the same time