search
HomeDatabaseMysql Tutorial关于 Oracle NULL栏位和PL./SQL执行实验

今日有针对Oracle NULL值有了相关实验. 对NULL 值插入的讨论。PL/SQL 中可以执行插入

今日有针对Oracle NULL值有了相关实验. 对NULL 值插入的讨论。

1, PL/SQL 中可以执行插入''或者NULL 的操作, 前提是栏位允许为空.

2, 可以对NULL进行一系列数据库运算. 如:

    SELECT ROUND(TO_NUMBER(MAX(A.IN_STATION_TIME)-SYSDATE))*24 FROM SFISM4.R_WIP_TRACKING_T A WHERE

      A.IN_STATION_TIME IS NULL

总结: 相应TO_NUMBER(NULL)也是可行, MAX 也是可行得,没有问题.

3, 回归主题, SQL 原本的样子要做成这个样:

  INSERT INTO SFISM4.R_DT_PCB_OVERTIME_T F

    (F.SERIAL_NUMBER,

    F.MODEL_NAME,

    F.LINE_NAME,

    F.PRODUCTION_TIME,

    F.INTERCEPT_TIME,

    F.EXPRIATUION_HOUR,

    F.STATE_FLAG,

    F.SEND_USER)

    (SELECT 'COCO111111111',

            'NIUBI1',

            '15555',

            NVL(NULL, MAX(A.IN_STATION_TIME)),

            SYSDATE,

            NVL(ROUND(TO_NUMBER(MAX(A.IN_STATION_TIME)-SYSDATE))*24, '0'),

            '1',

            '1'

      FROM SFISM4.R_WIP_LOG_T E

      WHERE E.SERIAL_NUMBER = 'COCO111111111') AND E.GROUP_NAME = 'SMTS')

结果, 部分执行后, 一条也不会插入. Insert 操作, 根据子查询, 如果子查询为空, 那么什么都不会插入.

4, 高潮来了-- 去掉子查询中的WHERE后, 即SELECT 条件都是肯定有值后, 居然将表E中全部记录插入. 啊, 幸亏是测试库, 数据量不大, 但是也执行了5s. 好吧, 异常. 全部删除!  可见根据结果集Insert还是需要慎重啊, 否则将多少垃圾数据在实际中.

5, 回归本意.  最终针对NULL值单独判定, 防止意外大量数据产生.

--------------------------------------分割线 --------------------------------------

rlwrap - 解决Linux下SQLPLUS退格、上翻键乱码问题

SQLPLUS spool 到动态日志文件名

Oracle SQLPLUS提示符设置

通过设置SQLPLUS ARRAYSIZE(行预取)加快SQL返回速度

PL/SQL Developer实用技巧分享

--------------------------------------分割线 --------------------------------------

本文永久更新链接地址:

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How do you alter a table in MySQL using the ALTER TABLE statement?How do you alter a table in MySQL using the ALTER TABLE statement?Mar 19, 2025 pm 03:51 PM

The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

How do I configure SSL/TLS encryption for MySQL connections?How do I configure SSL/TLS encryption for MySQL connections?Mar 18, 2025 pm 12:01 PM

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

How do you handle large datasets in MySQL?How do you handle large datasets in MySQL?Mar 21, 2025 pm 12:15 PM

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?Mar 21, 2025 pm 06:28 PM

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

How do you drop a table in MySQL using the DROP TABLE statement?How do you drop a table in MySQL using the DROP TABLE statement?Mar 19, 2025 pm 03:52 PM

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

How do you create indexes on JSON columns?How do you create indexes on JSON columns?Mar 21, 2025 pm 12:13 PM

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

How do you represent relationships using foreign keys?How do you represent relationships using foreign keys?Mar 19, 2025 pm 03:48 PM

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)?How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)?Mar 18, 2025 pm 12:00 PM

Article discusses securing MySQL against SQL injection and brute-force attacks using prepared statements, input validation, and strong password policies.(159 characters)

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools