Database base types and additions and deletions

Source: Internet
Author: User
Tags pear

Data type:

Integer type: bigint, int, smallint, mediumint, tinyint

Decimal type: decimal, numeric

Float type: Real, float, double

Bit type: bit

Character type: char, varchar, LongVarChar, longtext

Unicode character type: nchar, nvarchar

Textual: Text, Tinytext

Binary type: binary, varbinary

DateTime type: Date, time, DateTime, timestamp, year

The Datetime range is: 1753.1.1--9999.12.31

smalldatetime range is: 1900.1.1--2079.6.6

Create a database: Right-click the database, create a new database, enter a name for the database

Create with a statement

Create DATABASE Fruitgo

Create a table with a database, add column names to the table

Use fruitgocreate table fruit (Code int,name varchar (a), Price decimal (18,2), Chandi varchar (50))

Add data to the table and query the table:

Insert into fruit values (1, ' Apple ', 2.5, ' Yiyuan ') insert into fruit values (2, ' bananas ', 3.5, ' Hainan ') insert into fruit values (3, ' pear ', 2.5, ' Yantai ') insert into fruit values (4, ' grapes ', 4.5, ' Zhejiang ') insert into fruit values (5, ' Mango ', 5.5, ' Guangdong ') select * from fruit

Delete and change the data:

Query data:

SELECT * FROM fruit--query all select name from fruit--query a column select Name,chandi from fruit--query multiple columns, separated by commas select * FROM fruit where co de=4--query an entire row, condition query select name from fruit where code=2--query number 2 for the name of the fruit select Name,chandi from fruit where code=3-- Search for the name and origin of the fruit with number 3

Add Data:

Insert into fruit values (6, ' lychee ', 6.5, ' Hunan ') insert into fruit (code,name,price) VALUES (7, ' pineapple ', 6)

To modify the data:

Update fruit set price=5 where code=4--the price of the fruit numbered 4 is changed to 5update fruit set chandi= ' Nanjing ' where code=5--will be the origin of the fruit with number 5 changed to Nanjing

Delete data:

Delete from fruit--all delete delete from fruit where name= ' pear '--delete entire row of data named Pear

Database base types and additions and deletions

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.