chapter03_DELECT和UPDATE

本文详细介绍了如何在SQL中谨慎使用DELETE和UPDATE语句,包括如何通过预览SELECT语句来确认要删除或更新的记录,以及如何利用数学函数和运算改变列的内容。文章强调了在执行这些操作前进行验证的重要性。
  • DELETE FROM xxx WHERE ……

    WHERE 后面接着的内容可以用所有SELECT语句用到的内容

  • 谨慎使用DELETE,除非已经确认加入了精确的WHERE子句

    一个__技巧__是先用 SELECT替换DELETE,看看到底要删除哪些记录

  • UPDATE 可以一次更新很多列的内容,中间用逗号,连接

    示例

       UPDATE my_contacts SET id = 2, name = 'bochen', location = 'shanghai' WHERE id = 1;
    
  • UPDATE 可以运用数学函数和运算改变列的内容

    示例

      UPDATE my_contacts SET id = id + 1, name = UPPER(name) WHERE name = 'bochen';
    
  • 使用UPDATE时同样要谨慎,最好也是先用小技巧 (用SELECT替换UPDATE,看看到底要更新哪些记录)

def compare(self, block_name, base, target, belong_to='block'): ls_delete, ls_add, ls_update = [], [], [] match_func = CustomTextStrategyMiddleware(self._path_base).match if settings.MATCH_WITH_CHAPTER: text_delete_list, text_add_list, old_new_text_matched = self.do_match_with_chapter(base, target,match_func) else: text_delete_list, text_add_list, old_new_text_matched = self.do_match_normal(base, target,match_func) for old_text_item, new_text_item in old_new_text_matched: not_equal = [] not_equal_values = [] if old_text_item.text != new_text_item.text: not_equal.append('text') not_equal_values.append((old_text_item.text, new_text_item.text)) else: for old_char, new_char in zip_longest(old_text_item.get_chars(), new_text_item.get_chars(),fillvalue=None): if old_char is None or new_char is None: item_char = getattr(old_char, 'char', '') or getattr(new_char, 'char', '') # 忽略制表符空格的差异项 if item_char in ('\t', ' '): continue not_equal.append('text') not_equal_values.append((getattr(old_char, 'char', ''), getattr(new_char, 'char', ''))) elif not getattr(old_char, 'char', '').strip() and not getattr(new_char, 'char', '').strip(): continue else: attrs, values = self.get_not_equal_attrs(old_char, new_char, settings.TEXT_COMPARE_ATTRS) not_equal.extend(attrs) not_equal_values.extend(values) unique_not_equal = list(set(not_equal)) unique_not_equal_values = [not_equal_values[not_equal.index(v)] for v in unique_not_equal] if not_equal: ls_update.append( DiffItem('update', 'text', 'text', block_name=block_name, old=old_text_item, new=new_text_item, belong_to=belong_to, diff_point=' '.join(unique_not_equal),diff_values=unique_not_equal_values)) for delete_item in text_delete_list: ls_delete.append(DiffItem('delete', 'text', 'text', block_name=block_name, old=delete_item, new=None, belong_to=belong_to)) for add_item in text_add_list: ls_add.append(DiffItem('add', 'text', 'text', block_name=block_name, old=None, new=add_item, belong_to=belong_to)) ret = { 'update': ls_update, 'add': ls_add, 'delete': ls_delete } return ret def compare(self, block_name, base, target, belong_to='block'): ls_delete, ls_add, ls_update = [], [], [] match_func = CustomTextStrategyMiddleware(self._path_base).match if settings.MATCH_WITH_CHAPTER: text_delete_list, text_add_list, old_new_text_matched = self.do_match_with_chapter(base, target,match_func) else: text_delete_list, text_add_list, old_new_text_matched = self.do_match_normal(base, target,match_func) for old_text_item, new_text_item in old_new_text_matched: not_equal = [] not_equal_values = [] if old_text_item.text != new_text_item.text: not_equal.append('text') not_equal_values.append((old_text_item.text, new_text_item.text)) else: for old_char, new_char in zip_longest(old_text_item.get_chars(), new_text_item.get_chars(),fillvalue=None): if old_char is None or new_char is None: item_char = getattr(old_char, 'char', '') or getattr(new_char, 'char', '') # 忽略制表符空格的差异项 if item_char in ('\t', ' '): continue not_equal.append('text') not_equal_values.append((getattr(old_char, 'char', ''), getattr(new_char, 'char', ''))) elif not getattr(old_char, 'char', '').strip() and not getattr(new_char, 'char', '').strip(): continue else: attrs, values = self.get_not_equal_attrs(old_char, new_char, settings.TEXT_COMPARE_ATTRS) not_equal.extend(attrs) not_equal_values.extend(values) unique_not_equal = list(set(not_equal)) unique_not_equal_values = [not_equal_values[not_equal.index(v)] for v in unique_not_equal] if not_equal: ls_update.append( DiffItem('update', 'text', 'text', block_name=block_name, old=old_text_item, new=new_text_item, belong_to=belong_to, diff_point=' '.join(unique_not_equal),diff_values=unique_not_equal_values)) for delete_item in text_delete_list: ls_delete.append(DiffItem('delete', 'text', 'text', block_name=block_name, old=delete_item, new=None, belong_to=belong_to)) for add_item in text_add_list: ls_add.append(DiffItem('add', 'text', 'text', block_name=block_name, old=None, new=add_item, belong_to=belong_to)) ret = { 'update': ls_update, 'add': ls_add, 'delete': ls_delete } return ret def compare(self, block_name, base, target, belong_to='block'): ls_delete, ls_add, ls_update = [], [], [] match_func = CustomTextStrategyMiddleware(self._path_base).match if settings.MATCH_WITH_CHAPTER: text_delete_list, text_add_list, old_new_text_matched = self.do_match_with_chapter(base, target,match_func) else: text_delete_list, text_add_list, old_new_text_matched = self.do_match_normal(base, target,match_func) for old_text_item, new_text_item in old_new_text_matched: not_equal = [] not_equal_values = [] if old_text_item.text != new_text_item.text: not_equal.append('text') not_equal_values.append((old_text_item.text, new_text_item.text)) else: for old_char, new_char in zip_longest(old_text_item.get_chars(), new_text_item.get_chars(),fillvalue=None): if old_char is None or new_char is None: item_char = getattr(old_char, 'char', '') or getattr(new_char, 'char', '') # 忽略制表符空格的差异项 if item_char in ('\t', ' '): continue not_equal.append('text') not_equal_values.append((getattr(old_char, 'char', ''), getattr(new_char, 'char', ''))) elif not getattr(old_char, 'char', '').strip() and not getattr(new_char, 'char', '').strip(): continue else: attrs, values = self.get_not_equal_attrs(old_char, new_char, settings.TEXT_COMPARE_ATTRS) not_equal.extend(attrs) not_equal_values.extend(values) unique_not_equal = list(set(not_equal)) unique_not_equal_values = [not_equal_values[not_equal.index(v)] for v in unique_not_equal] if not_equal: ls_update.append( DiffItem('update', 'text', 'text', block_name=block_name, old=old_text_item, new=new_text_item, belong_to=belong_to, diff_point=' '.join(unique_not_equal),diff_values=unique_not_equal_values)) for delete_item in text_delete_list: ls_delete.append(DiffItem('delete', 'text', 'text', block_name=block_name, old=delete_item, new=None, belong_to=belong_to)) for add_item in text_add_list: ls_add.append(DiffItem('add', 'text', 'text', block_name=block_name, old=None, new=add_item, belong_to=belong_to)) ret = { 'update': ls_update, 'add': ls_add, 'delete': ls_delete } return ret 详细解析
11-05
【多变量输入超前多步预测】基于CNN-BiLSTM的光伏功率预测研究(Matlab代码实现)内容概要:本文介绍了基于CNN-BiLSTM模型的多变量输入超前多步光伏功率预测方法,并提供了Matlab代码实现。该研究结合卷积神经网络(CNN)强大的特征提取能力与双向长短期记忆网络(BiLSTM)对时间序列前后依赖关系的捕捉能力,构建了一个高效的深度学习预测模型。模型输入包含多个影响光伏发电的气象与环境变量,能够实现对未来多个时间步长的光伏功率进行精确预测,适用于复杂多变的实际应用场景。文中详细阐述了数据预处理、模型结构设计、训练流程及实验验证过程,展示了该方法相较于传统模型在预测精度稳定性方面的优势。; 适合人群:具备一定机器学习深度学习基础,熟悉Matlab编程,从事新能源预测、电力系统分析或相关领域研究的研发人员与高校研究生。; 使用场景及目标:①应用于光伏电站功率预测系统,提升电网调度的准确性与稳定性;②为可再生能源并网管理、能量存储规划及电力市场交易提供可靠的数据支持;③作为深度学习在时间序列多步预测中的典型案例,用于科研复现与教学参考。; 阅读建议:建议读者结合提供的Matlab代码进行实践操作,重点关注数据归一化、CNN特征提取层设计、BiLSTM时序建模及多步预测策略的实现细节,同时可尝试引入更多外部变量或优化网络结构以进一步提升预测性能。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值