SQL Server 2008 First day of learning

Source: Internet
Author: User
Tags sql server tutorial

Because of hobbies, decided to start self-learning SQL Server Tutorial today, to record the daily learning situation, so as to spur themselves. Well, the nonsense is not much to say, the following for today to learn the content:

SQL Server is a relational database management system launched by Microsoft Corporation. With ease of use scalability and the high degree of integration of related software, you can span multiple platforms, from laptops running Microsoft Windows 98 to large multiprocessor servers running Microsoft Windows 2012. SQL Server uses the language as the SQL language (statement), also called the Structured Query language.

Here are some of the most basic and introductory SQL statements
--Create a database
Create DATABASE name
--Modify the database name
EXEC sp_renamedb database name, new database name
--Delete Database
Drop database name

Common terminology in databases

Relationship : A relationship is a two-dimensional table, each relationship has a relationship name, which is usually the name of a table that we often hear.

Records: rows in a table, called Records

field: that is, the value range such as: Time value, 08:00-13:00, age must be a number cannot be a Chinese character, etc.

Association: refers to the way data between different database tables is connected to each other

keywords: a combination of attributes or attributes that can be used to uniquely indicate a record such as: Our ID number, student number, etc.

External keywords: If a field in a table is not a keyword in this table but a keyword in another table, this can be called an external keyword.

data redundancy: refers to duplicate data in a database

Data integrity: A field data type must be consistent must conform to the rules cannot violate

Insert Exception Update Exception Delete exception

These three exceptions usually refer to the fact that there is no contradiction in the database in order to ensure the relational nature of multiple table data

--------------------------------------------------------------------------------------------------------------- ------------------------------

To create a database specific steps:

Create database name--Creating database name

On (name= database name _data,--database name

Filename= ' d:\temp\ database _data.mdf ',--database file

size=6,--database file Initial Size

MAXSIZE=12,--Maximum database

filegrowth=10%--More than 10% growth per cent)

Log on--description of the transaction log file

(

Name= database name _log,

Filename= ' d:\temp\ database name _log.ldf ',

Size=1,

Maxsize=8,

filegrowth=10%

)

Steps to create a table:

Use database

--Open Database CREATE TABLE table name --Create a table

(

Number--field

Name

)

Query Table statement:

SELECT * from table name;

Modifying the database--(adding database files)

ALTER DATABASE

Add File

(

Name= Database 2,

file= ' d:\temp\ database. mdf '

Size=6

)

Modify Database--(Increase transaction log file)

ALTER DATABASE

Add log file

(

Name= database _LOG2,

Filename= ' d:\temp\ database _log2.ldf '

filegrowth=10%

)

Delete a database file

ALTER DATABASE

Remove file database files--for storing data

Delete a database transaction log file

ALTER DATABASE

Remove file database thing log file _LOG2--all operations are recorded in the transaction log file

Modify a table name in the database

EXEC sp_rename "table name", "New table name"

Add a field to a table in the database

Use database

ALTER TABLE table name

Add Field name data type

--Fill the default value for the newly added field

Add field name data type default ' auto-populated value '

Well, the above for the first day of the study of Things, hereby recorded, easy to review later, Hope also to the later study younger brothers learn to bring a little help

Because this note for me to open the video process and through their own understanding of the written, so what errors in the text, but also ask seniors to give more advice.

SQL Server 2008 First day of learning

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.