November 14, 2016--sql CREATE DATABASE, table-check, insert, delete, change

Source: Internet
Author: User
Tags sql create database

--Create a database
Create DATABASE hq20161114
Go


--Using the database
Use hq20161114
Go


--Create student tables
CREATE TABLE Xuesheng
(
code int,
Name varchar (10),
Sex char (10),
Chengji Decimal (18,2)
)


--Add student information
INSERT into Xuesheng values (1001, ' One ', ' male ', 11)
INSERT into Xuesheng values (1002, ' two ', ' Male ', 22)
INSERT into Xuesheng values (1003, ' three ', ' female ', 33)
INSERT into Xuesheng values (1004, ' four ', ' female ', 44)
Go


--Querying data
SELECT * FROM Xuesheng

--Query data Specify single column
Select name from Xuesheng

--Querying data specifying multiple columns
Select Name,chengji from Xuesheng

--based on the conditions of the query score of more than 20
SELECT * FROM Xuesheng where chengji>=20

--Query the results of female students according to the conditions
Select Chengji from Xuesheng where sex= ' woman '

--Change the gender of Student No. 3rd to Male
Update Xuesheng set sex= ' man ' where code=1003

--Delete all
Delete from Xuesheng

--Add No. 5th study
INSERT into Xuesheng values (1005, ' five ', ' female ', 55)


--delete the specified line
Delete from Xuesheng where name= ' five '

November 14, 2016--sql CREATE DATABASE, table-check, insert, delete, change

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.