Home  >  Article  >  Database  >  在Oracle数据库中插入含有符号的字符串

在Oracle数据库中插入含有符号的字符串

WBOY
WBOYOriginal
2016-06-07 17:27:121002browse

两种情况: 1、如果后面没有字符串,那么就是简单的字符,按照字符进行处理; 2、如果后面有字符串,那么按照Oracle的说法,就

两种情况:

1、如果&后面没有字符串,那么&就是简单的字符,按照字符进行处理;

2、如果&后面有字符串,,那么按照Oracle的说法,就应该将&后面的作为变量来进行操作,进行处理;

下面是针对上面两种情况的尝试:

T5240.com%

T5240.com% sqlplus '/ as sysdba'

SQL*Plus: Release 10.2.0.5.0 - Production on 星期二 3月 5 12:21:58 2013

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.

连接到:

Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

会话已更改。

SQL>

SQL> create table zzw_temp (name varchar2(20));

表已创建。

SQL> insert into zzw_temp(name) values('zzw');

已创建 1 行。

SQL> commit;

提交完成。

SQL> select * from zzw_temp;

NAME

--------------------

zzw

SQL> insert into zzw_temp(name) values('&');

已创建 1 行。

SQL> commit;

提交完成。

SQL> select * from zzw_temp;

NAME

--------------------

zzw

&

SQL>           

SQL>

SQL>

SQL> 

SQL> insert into zzw_temp(name) values('https://192.168.0.1/index.html&http'); 

输入 http 的值:  123

原值    1: insert into zzw_temp(name) values('https://192.168.0.1/index.html&http')

新值    1: insert into zzw_temp(name) values('https://192.168.0.1/index.html123')

insert into zzw_temp(name) values('https://192.168.0.1/index.html123')

                                  *

第 1 行出现错误:

ORA-12899: 列 "SYS"."ZZW_TEMP"."NAME" 的值太大 (实际值: 35, 最大值: 20)

SQL> alter table zzw_temp modify name varchar2(200);

表已更改。

SQL> insert into zzw_temp(name) values('https://192.168.0.1/index.html&http');

输入 http 的值:  123

原值    1: insert into zzw_temp(name) values('https://192.168.0.1/index.html&http')

新值    1: insert into zzw_temp(name) values('https://192.168.0.1/index.html123')

已创建 1 行。

SQL> select * from zzw_temp;

NAME

----------------------------------------------------------------------------------------------------------------------------------

zzw

&

https://192.168.0.1/index.html123

SQL> insert into zzw_temp(name) values('https://192.168.0.1/index.html'||'&'||'http');

已创建 1 行。

SQL> commit;

提交完成。

SQL> select * from zzw_temp;

NAME

----------------------------------------------------------------------------------------------------------------------------------

zzw

&

https://192.168.0.1/index.html123

https://192.168.0.1/index.html&http

SQL>     

SQL>

linux

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