SQL
星光汇
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
mysql同一个数据值,获取最新的一条数据
745454545454545454545原创 2022-09-29 11:03:01 · 1100 阅读 · 1 评论 -
mysql查询树节点
SELECT T2.*,T1.lvl FROM ( SELECT @r AS _id, (SELECT @r := parent_id FROM 数据库的表名 WHERE id = _id) AS parent_id, @l := @l + 1 AS lvl FROM (SELECT @r := '当前节点的ID', @l := 0) .原创 2022-03-07 19:57:21 · 675 阅读 · 0 评论 -
Mysql获取表结构数据,包括表的注释和字段的注释,可用于导出表结构数据
--查看表的元信息 select * from TABLES where TABLE_SCHEMA='数据库名称' and TABLE_NAME='表名称' --获取完整结构数据 SELECT table_name 表名, (select table_comment from TABLES where TABLE_SCHEMA='数据库名称' and TABLE_NAME=aa.tab...原创 2020-04-29 11:37:40 · 967 阅读 · 0 评论 -
数据库避免插入重复数据处理
oracle : insert when (not exists (select id from t_company_staff where name='赵国军4')) then into t_company_staff (name,status,APPLIEDTYPE) select '赵国军4',2,1 from dual; 或者 insert into t_company_st...原创 2019-05-05 19:50:10 · 893 阅读 · 0 评论 -
sqlserver2012导入sql大文件
osql -S 192.168.1.112 -U sa -P 123456 -i D:\1.sql ,-S 服务器名 -U 用户名 -P 密码 -i 文件地址,等待执行完毕即可以上在sql2012下执行通过如果数据库是 sql2008的 请将 osql 修改成为 sqlcmd 即可...转载 2018-03-23 10:30:01 · 4136 阅读 · 0 评论 -
查询单个库中所有表磁盘占用大小的SQL语句:
select TABLE_NAME, concat(truncate(data_length/1024/1024,2),' MB') as data_size,concat(truncate(index_length/1024/1024,2),' MB') as index_sizefrom information_schema.tables where TABLE_SCHEMA = 'TestD...转载 2018-02-10 19:56:31 · 414 阅读 · 0 评论 -
sql 获取当前系统时间
sql读取系统日期和时间的方法如下: --获取当前日期(如:yyyymmdd) select CONVERT (nvarchar(12),GETDATE(),112) --获取当前日期(如:yyyymmdd hh:MM:ss) select GETDATE() --获取当前日期(如:yyyy-mm-dd) Select Datename(year,GetDate())+'-'+Datenam转载 2017-03-22 14:14:48 · 5496 阅读 · 0 评论 -
sql根据其中一个字段去重复数据
//这个是排除了重复的数据 即重复数据不出现 select * from ProductFigure where ProductId in (select ProductId from ProductFigure group by ProductId having count(ProductId) = 1) //重复数据中只有第一条出现 其他数据正常显示 select s.* f...转载 2017-03-30 15:56:47 · 2669 阅读 · 0 评论 -
sql处理分母为0
select case when a=0 then 0 else a/b end转载 2017-07-11 09:30:16 · 3158 阅读 · 0 评论
分享