Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic operations of SQL server

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what are the basic operations of SQL server". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what are the basic operations of SQL server.

SQL server Foundation

1. Classification of SQL language

2. SQL server library & table operation and constraint

2.1 Library operations:

2.1.1 create a database:

2.1.2 modify the database:

2.1.3 Delete the database:

2.2 Table operations:

2.2.1 SQL server common data types:

2.2.2 create a table:

2.2.3 modify the table:

2.3 constraints

4. Operation of data

4.1 increase:

4.2 Delete:

4.3 change:

4.4 check:

1. Classification of SQL language

DDL data definition language: create drop alter

DQL data query language: select

DML data manipulation: insert update delete

DCL data control: grant revoke

2. SQL server library & table operation and constraint

2.1 Library operations:

2.1.1 create a database:

Create database database name

On (

Name= data file logical name

Filename=' path + data file name'

Initial size of size= data file

Maximum capacity of maxsize= data files

Automatic growth of filegrowth= data files

)

[log on (

Name = logical name of the log file

Filename=' path + log file name'

Initial size of size= data file

Maximum capacity of maxsize= data files

Automatic growth of filegrowth= data files

)]

one

two

three

four

five

six

seven

eight

nine

ten

eleven

twelve

thirteen

fourteen

fifteen

2.1.2 modify the database:

ADD FILE: adding data files to the database

Alter database database name

Euro symbol http://www.gendan5.com/currency/EUR.html

Add file (

Name= data file logical name

Filename=' path + data file name'

Initial size of size= data file

Maximum capacity of maxsize= data files

Automatic growth of filegrowth= data files

)

ADD LOG FILE: adding log files to the database

REMOVE FILE: delete logical files from the database and delete physical files. Cannot delete a file whose filegroup is not empty.

MODIFY FILE: specify the file to modify

one

two

three

four

five

six

seven

eight

nine

ten

eleven

twelve

2.1.3 Delete the database:

Drop database database name

one

2.2 Table operations:

2.2.1 SQL server common data types:

Int-4 byte

Float (5Power2)-8 bytes

Date- date type

Datetime- date and time type 8 bytes

Char (20)-White space characters are reserved at the end of a fixed length character

Varchar (22)-the trailing end of a non-fixed-length character removes white space characters

Image- binary string maximum 2GB

2.2.2 create a table:

Create table ([,.])

one

Add a federated primary key constraint when creating a datasheet: create table (, primary key (Field 1, Field 2))

one

2.2.3 modify the table:

ADD mode:

Alter table add

one

ALTER mode:

Alter table alter column

one

Note: the constraints here can only be modified NULL or NOT NULL, other types of constraints must be deleted before modification, and then re-add constraints. DROP mode

DROP mode is only applicable to delete integrity constraint definition alter table drop constraint

one

two

three

Delete the table:

Dorp table

one

2.3 constraints

Not null non-null constraint

Unique unique constraint

Primary key primary key constraint

[constraint] primary key (column name [{, column name}])

A table can have only one unique constraint

Foreign key foreign key constraint

[constraint] foreign key references ([{, column name}])

Check check constraints

[constraint] check ()

A table can define multiple check constraints, but only one check constraint can be defined per field

4. Operation of data

4.1 increase:

Insert into [list, [, …]] 4.2 Delete:

Change the delete from table name to where condition 4.3:

Update table name set column name = value where condition 4.4 look up:

Select * from table name condition query: select from table name condition

Conditional query

Common comparison operators: =, >

< , >

=

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report