insert into语句怎么用?

2024-11-15 22:52:17
推荐回答(1个)
回答1:

INSERT INTO 语句可以有两种用法:

1、第一种形式无需指定要插入数据的列名,只需提供被插入的值即可:

INSERT INTO table_name
VALUES (value1,value2,value3,...)

2、第二种形式需要指定列名及被插入的值:

INSERT INTO table_name (column1,column2,column3,...)
VALUES (value1,value2,value3,...)

其他SQL语句:

创建新数据库:CREATE DATABASE

修改数据库:ALTER DATABASE

创建新表:CREATE TABLE

变更(改变)数据库表:ALTER TABLE

删除表:DROP TABLE

创建索引(搜索键):CREATE INDEX

删除索引:DROP INDEX

删除主键:Alter table tabname drop primary key(col)

选择:select * from table1 where 范围

插入:insert into table1(field1,field2) values(value1,value2)

删除:delete from table1 where 范围

更新:update table1 set field1=value1 where 范围

查找:select * from table1 where field1 like ’%value1%’ 

排序:select * from table1 order by field1,field2 [desc]

总数:select count as totalcount from table1

求和:select sum(field1) as sumvalue from table1

平均:select avg(field1) as avgvalue from table1

最大:select max(field1) as maxvalue from table1

最小:select min(field1) as minvalue from table1