SQL Server Learning record Day1

Source: Internet
Author: User

 recently in the study of SQL Server database, with the version is R2 version, as shown, I study time is not long, write this article one is to exercise their deeper impression, two can also communicate with many friends and get everyone's advice.

  There are many installation tutorials online, you can search by yourself, but there are some small details when installing to the instance configuration, if there is no other version of SQL SERVER installed, select the default instance, if you have installed, specify the instance manually. If a computer has multiple instances of SQL Server installed, the ports for each instance are different, and you need to be aware when setting up server connection addresses in the software, for example: 192.168.0.1,1433, 192.168.0.1,1456. Account settings are best for mixed mode when server configuration and database engine configuration

Once you've installed it, you're ready to open the database.

Get a general idea of the database before you start learning the database

1. History of the database

Since the birth of human beings, there is the need to record data, in ancient times there is the story of the rope, and with the progress of science and technology, we recorded the way the data has changed, from low efficiency, small scale, can not adapt to the needs of rapid development of information Manual or simple mechanical recording information to a database management system created to accommodate the current high-speed development of information

The current database mainstream is the relational database, of course, the future data direction is object-oriented database, the characteristics of the relational database is to transform the object entity into a two-dimensional table for management, with simple, clear advantages

2. Basic concepts of the database

The database can be divided into four tiers from a large to a small size: Database systems > Database management Systems > Databases > data, information

Information: attribute reflection of objective things

Data: Recording information is the objective property of recording things

Database: Regular collation of data

Database management system: Managing the normal operation of the database

Database system: Composed of database, database management system, application system, database administrator and user

3. Several ways to turn on SQL Server

  1. Open the SQL Server2008 Configuration Manager

     

Turn on the SQL Server service

    

2.Dos Command Start

DOS command: NET start mssqlserver

3. Control Panel--Configuration tool--service

4. Task Manager--Services

Login database:

     

Server type: Database engine
Server name: IP address, this machine can be used. or computer name instead
Two ways to log in: Window authentication does not require a password
Password required for SQL authentication

Basic operations for 4.SQL server

  There are 4 default databases in SQL serve:

The database files are divided into two categories: Data file and log file.

5. Creating a database using SQL statements

To create a code template for a database

1 CREATE database name2  on3 (4 Name : logical name5 fileName: Physical name6 Size : Initial size7 filegrowth: The way of growth8 maxsiz: Maximum value9 )Ten Log on One ( A Name : logical name - fileName: Physical name - Size : Initial size the filegrowth: The way of growth - maxsiz: Maximum value - )
18--That's the bottom line. The code should be placed before the database is created.To determine if the database exists, to delete the re-create
19ifExists (SELECT * from sysdatabases where name= database name)--determine if a table exists +Drop database name

The following code simply creates a Demo_test database and creates a classes table that can be changed according to the template you want.

1Use master--using the specified database2 GO3 4--Create a database5 ifExists (SELECT * from sysdatabases where name = ' demo_test ')--determine if the database exists6 drop Database Demo_test7 8 CREATE DATABASE demo_test9On--Create a master data file (only one)Ten(name = ' Lg_data ',--Logical Name OneFileName = ' E:\SQL_Data\Data\Demo_data.mdf ',--Physical Name ASize = 3MB,--Initial Size -FileGrowth = 20%,--growth Mode -MaxSize = 30MB--Maximum size limit the ), - (  -name = ' Demo_data2 ', -FileName = ' E:\SQL_Data\Data\Demo_data2.ndf ', +Size =3MB, -FileGrowth = 20%, +MaxSize =30MB A ) atLog On--log File - ( -name = ' Demotest_log ',--Logical Name -FileName = ' E:\SQL_Data\Data\Demotest_log.ldf ',--Physical Name -Size =1MB, -FileGrowth =1MB in ) - Go

Summary:

The development of database is divided into 3 generations: Network (hierarchical) model database system, relational model database system, object-oriented database system
Today's mainstream databases are: Oracle, DB2, Sybase, SQL server,mysql, etc.
SQL Server 2008 is a reliable, efficient, intelligent data platform launched by Microsoft
SQL Server 2008 provides 4 system databases for storing system-level information
When you create a database, you must have a primary data file and a log file
Data tables are important objects in a database, and all data must be stored in a data table

SQL Server Learning record Day1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.