insert into

时间:2024-11-26 22:25:04编辑:优化君

insert into语句是什么?

insert into语句就是向表中添加数据,其简单语法形式为:Insert into 表名[(列名[,列名]...)] values(值 [,值],...)。Values 后面的值的排列要与into子句后面的列名排列一致,若表名后面的所有列名省略,则values后的值的排列要与该表中存储的列名排列一致,“[]”表示其中的内容可省略。语句形式为:SELECT vale1, value2 into Table2 from Table1,要求目标表Table2不存在,因为在插入时会自动创建表Table2,并将Table1中指定字段数据复制到Table2中。相关写法如下:写法1:INSERT INTO t1(field1,field2) VALUE(v001,v002);写法2:INSERT INTO t1(field,field2) VALUES(v101,v102)(v201,v202)(v301,v302)(v401,v402);写法3:INSERT INTO t2(field1,field2) SELECT col1,col2 FROM t1 WHERE。

insert into语句怎么用?

INSERT INTO 语句可以有两种用法:1、第一种形式无需指定要插入数据的列名,只需提供被插入的值即可:INSERT INTO table_nameVALUES (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

上一篇:青岛滨海学院怎么样

下一篇:没有了