有时我们在定义字段名及别名时所用名与oracle关键字同名,这时该如何处理呢,本文将详细介绍,需要了解的朋友可以参考下
有时我们在定义字段名及别名时所用名与oracle关键字同名,这时该如何处理呢?其实很简单,只要在此关键字加上"",如"group"
看下面的例子:
代码如下:
SQL> DROP TABLE k;
Table dropped
-- 建立表K,字段名为UID(oracle关键字)
SQL> CREATE TABLE k(UID INT);
CREATE TABLE k(UID INT)
ORA-00904: : invalid IDENTIFIER
-- 字段名加""表创建成功
SQL> CREATE TABLE k("UID" INT);
Table created
--插入一些数据
SQL> INSERT INTO k VALUES(1);
1 row inserted
SQL> INSERT INTO k VALUES(2);
1 row inserted
SQL> INSERT INTO k VALUES(3);
1 row inserted
-- 查询时加不加""都正常(似乎不太符合规范)
SQL> SELECT UID FROM k;
UID
----------
5
5
5
SQL> SELECT "UID" FROM k;
UID
---------------------------------------
1
2
3
-- update时必须加上""
SQL> UPDATE k SET UID=5 WHERE UID=3;
UPDATE k SET UID=5 WHERE UID=3
ORA-01747: invalid user.table.column, table.column, or column specification
SQL> UPDATE k SET "UID"=5 WHERE "UID"=3;
1 row UPDATED
总结:oracle可以在"关键字"的形式引用关键字作为字段名与查询语句的别名。如果不是特殊情况最好不要使用,以免引起代码编写过程中的错误。

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

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]

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

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

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.

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

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.

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


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools