Download presentation
Presentation is loading. Please wait.
Published byMeghan Butler Modified over 8 years ago
1
Enterprise Database Systems Introduction to SQL Server Dr. Georgia Garani garani@teilar.gr garani@teilar.gr Dr. Theodoros Mitakos teo_ms@yahoo.com Technological Educational Institution of Larissa in collaboration with Staffordshire University Larissa 2007
2
SQL SQL, pronounced ‘Sequel’ or simply S-Q-L, is a computer programming language that was developed especially for querying relational databases using a nonprocedural approach. The term nonprocedural means that you can extract information by simply telling the system what information is needed without telling it how to perform the data retrieval. Transact-SQL or T-SQL is Microsoft's implementation of the SQL language.
3
Procedural and Nonprocedural NonproceduralProcedural SELECT emp_last_name, emp_first_name FROM employee WHERE emp_last_name = 'BOCK'; intIndex = 1 DO WHILE intIndex <= Count_Of_Rows If emp_last_name = 'BOCK' Then If emp_last_name = 'BOCK' Then DISPLAY emp_last_name, DISPLAY emp_last_name, emp_first_name emp_first_name End If End If intIndex += 1 intIndex += 1LOOP
4
DATA Two types of data are stored within a database. Two types of data are stored within a database. User data: Data that must be stored by an organization. User data: Data that must be stored by an organization. System data: Data the database needs to manage user data to manage itself. This is also termed metadata, or the data about data. System data: Data the database needs to manage user data to manage itself. This is also termed metadata, or the data about data.
5
DBMS Services Data definition for defining and storing all of the objects that comprise a database such as tables and indexes Data definition for defining and storing all of the objects that comprise a database such as tables and indexes Data maintenance Data maintenance Data manipulation Data manipulation Data display Data display Data integrity Data integrity Data security Database backup and recovery Data security Database backup and recovery
6
SQL Server Versions EditionDescription SQL Server Standard Edition Small-and medium-sized businesses without large data center applications will find this edition best fits their budget. It supports up to four CPUs and 2GB of random access memory. SQL Server Enterprise Edition Aimed at large companies This version provides high availability and scalability. It can support up to 32 CPUs and 64GB of random access memory. SQL Server Developer Edition This is like the Enterprise Edition, but for system developers. It cannot be licensed for use in a production environment.
7
SQL Server Versions Contd. SQL Server Desktop Edition This Edition has the SQL Server database engine, but not all of the management tools or analysis services. Database size for this edition is limited to 2GB. It supports full application development and deployment for small business applications. SQL Server 2000 Personal Edition This version has much of the functionality of the Standard Edition. It can service small groups of concurrent access users. It will run on desktop Windows operating systems from Windows 98 to Windows 2000 Professional Edition. SQL Server 2000 Windows CE Edition This runs on the Windows CE operating system for pocket PC devices.
8
SQL Server Features FeatureDescription Internet standard support SQL Server uses Microsoft's new.NET technology to support data exchange across the Internet including new detailed support for the extensible-markup language, or XML. Scalability SQL Server can be used to build very large, multiprocessor systems. Security mechanisms SQL Server's sophisticated security mechanisms control access to sensitive data through an assortment of privileges, for example, the privilege to read or write specific information within a database. Backup and recovery SQL Server's sophisticated backup and recovery programs minimize data loss and downtime if problems arise.
9
SQL Server Features Cont. SQL Server Features Cont. Space managemen t SQL Servers automated space management capability makes it easy for a database administrator to manage disk space for storage. These capabilities also include the ability to specify subsequent allocations on how much disk space to set aside for future requirements. Open connectivity SQL Server's open connectivity functionality provides uninterrupted access to the database throughout the day. It also provides open connectivity to and from other vendors’ software. Tools and applications SQL Server provides a wide range of development tools, end-user query tools, and support for third- party software applications that are used to model business processes and data and to generate program language code automatically.
10
SQL Query Analyzer GUI can be used to: Create databases. Create databases. Develop, test, and debug stored procedures. Develop, test, and debug stored procedures. Run SQL scripts – these are miniature programs that contain either DDL or DML commands or a combination of these commands. An example would be a script to create a database, and then populate the tables in the database with data. Run SQL scripts – these are miniature programs that contain either DDL or DML commands or a combination of these commands. An example would be a script to create a database, and then populate the tables in the database with data. Optimize system performance. Optimize system performance. Analyze query plans – these are the plans that the DBMS generates for processing a query. Analyze query plans – these are the plans that the DBMS generates for processing a query. Maintain and manage statistics concerning database performance. Maintain and manage statistics concerning database performance. Generate tune table indexes – the indexes are supposed to improve system performance for data retrieval. Generate tune table indexes – the indexes are supposed to improve system performance for data retrieval.
11
SQL Query Analyzer Contd.
15
Creating a Database When SQL Server is initially installed, five system databases are generated. These are named: (1) master, (2) model, (3) msdb, (4) distribution, and (5) tempdb. When you create a new database in SQL Server, the DBMS uses the model database as a template to create a new database. The command to create a user database is : The command to create a user database is : CREATE DATABASE CREATE DATABASE Note: You must have prior authorization from your system administrator to execute this command.
16
Using a Database After you have CREATED your database(s) you must use the USE command to select a database for future processing. You can type the USE command into the Editor pane and execute it also. USE Company; The command(s) completed successfully.
17
Executing Scripts Sometimes you need to execute a script that contains a series of SQL statements. The Editor pane can be used to create and save a script Sometimes you need to execute a script that contains a series of SQL statements. The Editor pane can be used to create and save a script Simply select the Editor pane to make it the active window, then use the toolbar Save option and specify the location, file name, and file format when the Save Query dialog box displays. Simply select the Editor pane to make it the active window, then use the toolbar Save option and specify the location, file name, and file format when the Save Query dialog box displays. You should use the default filename extension of.sql when naming a script file. You should use the default filename extension of.sql when naming a script file.
18
Executing Scripts
19
You can also open scripts and execute them, even if they were created with another text editor, such as Microsoft Notepad or Word. You can also open scripts and execute them, even if they were created with another text editor, such as Microsoft Notepad or Word. Select the Load SQL Script toolbar button and when the Open Query File dialog box displays, locate and select the name of the file to be opened. Select the Load SQL Script toolbar button and when the Open Query File dialog box displays, locate and select the name of the file to be opened.
20
Executing Scripts
21
T-SQL Naming Rules There are several rules for naming database objects that must be followed: Identifiers can consist of letters, digits, or the symbols #, @, $, and _ (underscore). Identifiers must be no more than 128 characters Identifiers must be no more than 128 characters The first character of an identifier must be either a letter (a- z, A-Z) or the #, @ or _ (underscore) symbol. After the first character, you may use digits, letters, or the symbols $, #, or _ (underscore). Temporary objects are named by using the # symbol as the first character of the identifier. Avoid using this symbol as the leading character when naming permanent database objects. The @ symbol as the first character of an identifier denotes a variable name. Avoid using this symbol as the leading character when naming other database objects. SQL keywords such as SELECT and WHERE cannot be used as an identifier.
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.