Querying, backing up data, creating a database

Source: Internet
Author: User

Query: Right-click on the first 1000 rows of a new table selection query

Backup data: Database name Right-click, there is a task, go to the inside of the backup, (backup copy has a time, from the inside design time), copy only the backup that hit a √, click OK, it's done


The file that ends with. bak is the backup file for the database.


Detach: There's a separation in the right button.
Attach: Right click on the database, attach, find the address of the file placed on the computer, click OK, add the database (additional suffix is. mdf file)

New query
Code creation database Create DB Ssdata
Ctrl+s is saved: saved in document by default
--Comments, one line
/**/representative notes a paragraph
Go play the role of cohesion, can write not write
Use represents the name of the database that is directly written after the database is selected
Drop Database Ssdata Delete databases
CREATE TABLE student ()
The code represents the column name int not NULL, (the NOT NULL means cannot be empty, separated by ",")
The last column of "," can be omitted
The DBO represents the system architecture


ALTER TABLE student Add sex int (modify table, add column)
--Modify Table Delete column
ALTER TABLE student drop column sex
--Delete the entire table
DROP TABLE Student
--inserting data into a table (insert only one piece of data at a time)
INSERT into student values (1, ' Zhang San ', 1990-09-22)

Querying all data in a table
Select *from Student

--Modify data
Update student Set birthday = ' 1990-09-09 '
--Delete data
Delete from student
Delete from student where name= "Harry"


Create: Creation, creation, production
Table: Tables
Alter: Change, change
Sex: Identifying and distinguishing
Select: Query, find
Update: updating, modernizing, correcting, correcting
From: Where
Insert: Inserting, embedding
Delete: Remove
Drop: Terminate

Primary key and foreign key
Primary key: Is an index, help us quickly find, in the database to take out a column as the primary key, data is the only non-repeatable data can not be empty data, slowing down the new data
Right-click Table, point design, right-click column, set as primary key
Primary KEY Key Key
Identity (+)
Identity specification (is identity) identity seed (set int type)

Querying, backing up data, creating a database

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.