A.B两表,找出ID字段中,存在A表,但是不存在B表的数据. 方法一:使用 not inselect distinct A.ID from A where A.ID not in (select ID from B) 方法二:使用 left join...on... , "B.ID isnull" 表示左连接之后在B.ID 字段为 null的记录select A.ID from A left join B on A.ID=B.ID where B.ID is null 方法三:sele
1.查询表中重复数据.select * from peoplewhere peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)2.删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录delete from people where peopleId in (select peopleId
select from命令用来查询表中的数据. 1) 查询所有行命令格式: select <字段1, 字段2, ...> from < 表名 > where < 表达式 >; 例如,查看表 MyClass 中所有数据: mysql> select * from MyClass; 2) 查询前几行数据例如,查看表 MyClass 中前2行数据: mysql> select * from MyClass order by id limit 0,2; s
脚本如下: #!/bin/bash mysql -s -phello test >.log <<EOF desc t1; EOF lines="concat_ws(','," count=`.log|wc -l` linenum= while read line do coloumname=`echo $line |awk '{print $1}'` let linenum=linenum+ ];then lines=$lines"concat_ws(':'
--1.先建表 CREATE TABLE test(idd INT NOT NULL,name VARCHAR(10) NULL) INSERT INTO TEST SELECT 1,'abcdefg' UNION ALL SELECT 2,'hijklmn' --SELECT * FROM TEST SELECT * FROM sys.tables WHERE name = 'test' --2.查询元数据 --hobt_id : 72057594043236352 SELECT hobt_i
无意间看到一篇文章,觉得对于ORACLE的新手很实用,特转载,原文出处这里 说明:在创建数据库时输入的密码,是修改系统默认的密码,以system和sysman等系统默认身份登录时要输入的密码就是修改后的密码(创建数据库时输入的密码)如果要创建新的用户就必须以system或者sysman(这二者的权限最大)的身份登录后才可创建创建用户格式:create user 用户名 identified by 密码(例如:create user cht identified by cht;)创建完成后,必须分
转载自http://blog.csdn.net/cuker919/article/details/8514253 select segment_name, bytes as 大小 from user_segments where segment_type = 'TABLE' and segment_name in ('VIEW_JLZDH_MP_DL_DAY_01','VIEW_JLZDH_MP_DL_DAY_02','VIEW_JLZDH_MP_DL_DAY_03', 'VIEW_JLZDH_
有两种含义的表大小.一种是分配给一个表的物理空间数量,而不管空间是否被使用.可以这样查询获得字节数: select segment_name, bytes from user_segments where segment_type = 'TABLE'; 或者 Select Segment_Name,Sum(bytes)/1024/1024 From User_Extents Group By Segment_Name 另一种表实际使用的空间.这样查询: analyze table emp c
1.测试表创建,插入数据: create table a (id int, name )); create table b (id int); ,'a'); ,'b'); ,'c'); ,'d'); ,'e'); ); ); 2.查询b表中存在的id不出现在a表中的内容,可用语句: select * from a where id not in (select id from b); 3.结果: demo 查询泊位表中地磁编号在地磁表中没有的 SELECT P.GEIMAGNETIC_ID FR
1.查询表中所有数据 select * from 表名; 例:select * from stu; 2.查询的同时修改表中数据 select * from 表名 for update; 例:select * from stu for update; 3.往表中添加数据 insert into 表名(列1,列2...) values(值1,值2...); 例:insert into stu(id,name,age) values(1,'zhangsan',23); 注意:字符串类型要用单引号括起
1.查询表中反复数据. select * from people where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1) 2.删除表中多余的反复记录,反复记录是依据单个字段(peopleId)来推断.仅仅留有rowid最小的记录 delete from people where peopleId in (select peop
DQL 查询表中的数据:查询语句(最复杂的语句)不会对数据库中的数据进行修改,只是一种显示数据的方式 语法格式: select 字段列表 from 表名列表 where 条件列表 group by 分组字段 having 分组之后的条件 order by 排序 limit 分页限定 一.基础查询 1.查询表所有行和列的数据,使用*表示所有列 select * from 表名; 2.查询指定列 select 字段名1,字段名2,字段名3,... from 表名; 3.指定列的别名进行查询 使用别名
声名:a,b ,都是表 复制代码代码如下: --b表存在(两表结构一样) insert into b select * from a 若两表只是有部分(字段)相同,则 复制代码代码如下: insert into b(col1,col2,col3,col4,...) select col1,col2,col3,col4,... from a where... 把表a插入到表b中去. 复制代码代码如下: --b表不存在 select * into b from a // select (