记录几个sql语句

本文介绍了如何使用SQL进行数据插入、查询重复项及复制表结构等实用技巧。包括插入带有时间戳和null值的数据、确保数据唯一性的插入方法以及如何查询表中重复的数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、插入带时间与null值的

insert into product values(null,'','20422REV','','','','','','','','','','','','',getdate(),getdate(),'','hl-qc','','')

 

 

2、插入不重复的数据的

insert into product select other1,other2,other3,other4,other5,other6,other7 from product_temp where not exists(select * from product where other1=product_temp.other1 or other2=product_temp.other2)

 

insert into product select item,ref,other_item,rose_item,rose_len,leaf_item,leaf_len,base_item,base_len,others1,others2,others3,others4,item_check,qc_check,pic_date,add_date,adder,pic,pichave,item_sort from product2 where not exists(select * from product where item=product2.item or other_item=product2.other_item)

 

3、查询重复的数据的

select * from product_temp where not exists(select * from product where other1=product_temp.other1 or other2=product_temp.other2)

 

4、复制表结构的

select * into product1 from product where 1=2

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值