有没有任何ISO标准的如何在DDL写SQL查询? [英] Is there any ISO standard of how to write SQL queries in DDL?
问题描述
我正在做我的第一个数据库项目。
I am doing my first database project.
我想知道在DDL中使用以下哪种方式来进行SQL查询。
I would like to know which of the following ways should I use to make SQL queries in DDL.
CREATE TABLE employees (
id INTEGER PRIMARY KEY,
first_name CHAR(50) NULL,
last_name CHAR(75) NOT NULL,
dateofbirth DATE NULL
);
#2
#2
CREATE TABLE employees (
id INTEGER PRIMARY KEY,
first_name CHAR(50) NULL,
last_name CHAR(75) NOT NULL,
dateofbirth DATE NULL
);
#3
#3
CREATE TABLE employees (
ID integer PRIMARY KEY,
FIRST_NAME char(50) NULL,
LAST_NAME char(75) NOT NULL,
DATAOFBIRTH data NULL
);
推荐答案
所以你通常应该去更可读和可维护。有很多不同的约定,我在它们之间切换,根据情况,所有的时间。
It doesn't really matter to the database, and so you should generally go for what's more readable and maintainable. There are a lot of different conventions out there, and I switch between them depending on circumstances all the time. Imo, what's good for a small query isn't the same as what's good for a more-complicated query.
在这种情况下,我认为你的#3看起来最容易阅读。但这只是我的意见,如果有代码看起来你的方式的惯例或现有的期望,坚持。
In this case, I think your #3 looks most readable. But that's just my opinion and if there are conventions or existing expectations for how the code looks where you are, stick to that.
这篇关于有没有任何ISO标准的如何在DDL写SQL查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!