时间:2021-07-01 10:21:17 帮助过:13人阅读
INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值2,....)
UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值
SELECT TOP number|percent column_name(s) FROM table_name
Mysql:
SELECT column_name(s)
FROM table_name
LIMIT number
SELECT * FROM Persons WHERE City LIKE ‘%lon%‘ :表明居住地包括lon
SELECT * FROM PersonsWHERE City NOT LIKE ‘%lon%‘:表明居住地不包括lon
SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...) (在一个范围内找某个值)
SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2 (在两个值之间)
SELECT LastNameAS Family
, FirstNameAS Name
FROM Persons (为某个列命名)
CREATE DATABASE my_db 数据库创建
CREATE TABLE Persons //创建新表 ( Id_P int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) )
CREATE INDEX index_name//创建索引
ON table_name (column_name)
DROP INDEX index_name ON table_name//创建索引
//
CREATE TABLE Persons (P_Id int NOT NULL AUTO_INCREMENT,
LastName varchar(255) NOT NULL, FirstName varchar(255), Address varchar(255), City varchar(255),PRIMARY KEY (P_Id)
) Auto-increment 会在新记录插入表中时生成一个唯一的数字。
///
视图表一般只做查询,可以通过视图修改基本表数据
SQL函数:
SELECT AVG(column_name) FROM table_name //求平均值
还有求最大值max, 最小值min,求和sum,
数据库01
标签:first 最小 null delete alter 生成 均值 percent index