数据操作 插入数据(记录): 用insert: 补充:插入查询结果: insert into 表名(字段1,字段2,...字段n) select (字段1,字段2,...字段n) where ...; 更新数据update 语法: update 表名 set 字段1=值1,字段2=值2 where condition; 删除数据delete:delete from 表名 where condition; 查询数据select: 单表查询: 语法: select distinct 字段1,字段2.
创建表mm: 其中id为主键且自增长 ) primary key not null unique auto_increment, name ) not null, age ), class ) not null ); 为表mm,插入数据 insert into mm(id,name,age,class) values (,,'XY'), (,,'uuy'), (,,'lf'); 修改表名mm为students: alter table mm rename students; 删除mm表里所有的
1.使用union和union all合并两个查询结果:select 字段名 from tablename1 union select 字段名 from tablename2: 注意这个操作必须保证两张表字段相同,字段数据类型也相同.另外,使用union的时候会去除重复(相同)的记录,而union all则不会. 注:下边的几个连接查询涉及到笛卡尔积的概念,即如果存在两张表,第一张记录数为n条,另一张表的记录数为m条,那么笛卡尔积得出的记录数就是n*m条:如果第一张表的字段数为a个,另一张的字段
1.使用union和union all合并两个查询结果:select 字段名 from tablename1 union select 字段名 from tablename2: 注意这个操作必须保证两张表字段相同,字段数据类型也相同.另外,使用union的时候会去除重复(相同)的记录,而union all则不会. 注:下边的几个连接查询涉及到笛卡尔积的概念,即如果存在两张表,第一张记录数为n条,另一张表的记录数为m条,那么笛卡尔积得出的记录数就是n*m条:如果第一张表的字段数为a个,另一张的字段
查询所有表名:select t.table_name from user_tables t;查询所有字段名:select t.column_name from user_col_comments t;查询指定表的所有字段名:select t.column_name from user_col_comments t where t.table_name = 'BIZ_DICT_XB';查询指定表的所有字段名和字段说明:select t.column_name, t.column_name from