Comments (2)
谢谢关注使用。空值产生的sql是空字符串。你的NULL的出现,请描述一下上下文?谢谢
(是不是你用产生的sql插入数据?然后确认一下你对应字段的设置,是不是允许为空?等)
from sqlgen.
比如我有一张这样的表:
CREATE TABLE t1
(
id
int(11) NOT NULL AUTO_INCREMENT,
tt
varchar(10) DEFAULT NULL,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
其中 tt字段是可为空的varchar字段。
t1表中的数据如下:
mysql> select * from t1;
+----+--------+
| id | tt |
+----+--------+
| 2 | NULL |
| 3 | NULL |
| 4 | NULL |
| 5 | NULL |
| 6 | NULL |
| 7 | NULL |
| 8 | NULL |
| 10 | 康康 |
| 11 | NULL |
+----+--------+
9 rows in set (0.00 sec)
mysql> select id,length(tt) from t1;
+----+------------+
| id | length(tt) |
+----+------------+
| 2 | NULL |
| 3 | NULL |
| 4 | NULL |
| 5 | NULL |
| 6 | NULL |
| 7 | NULL |
| 8 | NULL |
| 10 | 6 |
| 11 | 4 |
+----+------------+
9 rows in set (0.00 sec)
其中只有id=11的那行记录tt的值为'NULL',其他都是NULL(真正的空值),但是经过sqlgen产生的sql语句把所有'NULL'以及NULL值都转化成了'NULL':
[root@centos69 ~]# awk -f sqlGen.awk t1.txt
insert into t1(id,tt)values('2','NULL');
insert into t1(id,tt)values('3','NULL');
insert into t1(id,tt)values('4','NULL');
insert into t1(id,tt)values('5','NULL');
insert into t1(id,tt)values('6','NULL');
insert into t1(id,tt)values('7','NULL');
insert into t1(id,tt)values('8','NULL');
insert into t1(id,tt)values('10','康康');
insert into t1(id,tt)values('11','NULL');
from sqlgen.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlgen.