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