插入默认值 [英] insert DEFAULT values

查看:114
本文介绍了插入默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个语句之间有什么区别吗?:

Is there ANY difference between those two statements?:

INSERT INTO distributors (did, dname) VALUES (DEFAULT, 'XYZ Widgets');

和:

INSERT INTO distributors (dname) VALUES ('XYZ Widgets');

我的意思是至少有一个原因在某些特定情况下使用一种或另一种模式完全一样吗?
所做的是一个串行列。

I mean is there at least one reason to use one or another pattern in some particular situation or is it completely the same? did is a serial column.

推荐答案

这是完全一样的东西。无需选择一个而不是另一个。

It's exactly the same thing. No need to pick one instead of the other.

通常,当您拥有计算机生成的代码时, default 关键字非常有用。仅使用insert子句中的每一列,而对于某些列没有特定值时,只需使用 default 即可使工作变得更加轻松。

Usually default keyword is handy when you have computer-generated code. It makes life easier to just use every single column in the insert clause and just use default when you don't have a specific value for certain column.

除此之外,就像我说的一样。

Other than that, as I said, it's the same.

这篇关于插入默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆