* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Introduction to SQL Server
Survey
Document related concepts
Tandem Computers wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Oracle Database wikipedia , lookup
Extensible Storage Engine wikipedia , lookup
Team Foundation Server wikipedia , lookup
Concurrency control wikipedia , lookup
Ingres (database) wikipedia , lookup
Microsoft Access wikipedia , lookup
Functional Database Model wikipedia , lookup
Microsoft Jet Database Engine wikipedia , lookup
Relational model wikipedia , lookup
Database model wikipedia , lookup
Clusterpoint wikipedia , lookup
Open Database Connectivity wikipedia , lookup
Transcript
Enterprise Database Systems Introduction to SQL Server Technological Educational Institution of Larissa in collaboration with Staffordshire University Larissa 2007 Dr. Georgia Garani [email protected] Dr. Theodoros Mitakos [email protected] 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. Procedural and Nonprocedural Nonprocedural SELECT emp_last_name, emp_first_name FROM employee WHERE emp_last_name = 'BOCK'; Procedural intIndex = 1 DO WHILE intIndex <= Count_Of_Rows If emp_last_name = 'BOCK' Then DISPLAY emp_last_name, emp_first_name End If intIndex += 1 LOOP DATA • • • Two types of data are stored within a database. 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. DBMS Services • • • • • • Data definition for defining and storing all of the objects that comprise a database such as tables and indexes Data maintenance Data manipulation Data display Data integrity Data security Database backup and recovery SQL Server Versions Edition SQL Server Standard Edition Description 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. 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 This version has much of the functionality of the 2000 Personal Standard Edition. It can service small groups of Edition concurrent access users. It will run on desktop Windows operating systems from Windows 98 to Windows 2000 Professional Edition. SQL Server This runs on the Windows CE operating system 2000 for pocket PC devices. Windows CE Edition SQL Server Features Feature Description 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 SQL Server's sophisticated security mechanisms control access mechanisms 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. SQL Server Features Cont. Space SQL Servers automated space management managemen capability makes it easy for a database t 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 SQL Server provides a wide range of development applications tools, end-user query tools, and support for thirdparty software applications that are used to model business processes and data and to generate SQL Query Analyzer GUI can be used to: Create databases. 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. Optimize system performance. Analyze query plans – these are the plans that the DBMS generates for processing a query. Maintain and manage statistics concerning database performance. Generate tune table indexes – the indexes are supposed to improve system performance for data retrieval. SQL Query Analyzer Contd. SQL Query Analyzer Contd. SQL Query Analyzer Contd. SQL Query Analyzer Contd. 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 : CREATE DATABASE <database_name> Note: You must have prior authorization from your system administrator to execute this command. 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. 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 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. Executing Scripts Executing Scripts • • 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. Executing Scripts 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 The first character of an identifier must be either a letter (az, 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.