随笔分类 - 数据库
摘要:MySQL中group_concat函数完整的语法如下:group_concat([DISTINCT] 要连接的字段 [Order BY ASC/DESC 排序字段] [Separator '分隔符']) 基本查询 Sql代码 收藏代码select * from aa; +------+----...
阅读全文
摘要:allst=toconn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY); allsql = "SELECT distinct docid,docchannel FROM isimpor...
阅读全文
摘要:createStatement(int resultSetType,int resultSetConcurrency)参数一:结果集类型可取值: 1.ResultSet.TYPE_FORWORD_ONLY,结果集只可向前滚动; 2.ResultSet.TYPE_SCROLL_INSENSITIVE...
阅读全文
摘要:1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引。 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如:select id from t where num is null可以在nu...
阅读全文
摘要:分页查询公式:select top PageRow(每页显示的数据行数) from 表名 where 主键 not in(select top PageRow*(当前页数-1) 主键 from 表名);
阅读全文
摘要:db2 => create table test (name char(8) not null primary key,depid smallint,pay bigint)DB20000I SQL 命令成功完成。db2 => create table test1 (name char(8) not ...
阅读全文
摘要:1、查找员工的编号、姓名、部门和出生日期,如果出生日期为空值,显示日期不详,并按部门排序输出,日期格式为yyyy-mm-dd。 select emp_no,emp_name,dept,isnull(convert(char(10),birthday,120),'日期不详') birthdayfrom...
阅读全文
摘要:DB2数据库的内置数据类型主要分成数值型(numeric)、字符串型(character string)、图形字符串(graphic string)、二进制字符串型(binary string)或日期时间型(datetime)。还有一种叫做 DATALINK 的特殊数据类型。DATALINK 值包含...
阅读全文
摘要:一、交叉连接(cross join)交叉连接(cross join):有两种,显式的和隐式的,不带on子句,返回的是两表的乘积,也叫笛卡尔积。例如:下面的语句1和语句2的结果是相同的。 语句1:隐式的交叉连接,没有cross join。select o.id, o.order_number, c.i...
阅读全文
摘要:数据库最常用语句 1、复制表(只复制结构,源表名:a 新表名:b) 法一:select * into b from a where 11 法二:select top 0 * into b from a 2、拷贝表(拷贝数据,源表名:a 目标表名:b)insert into b(a, b, c...
阅读全文

浙公网安备 33010602011771号