sql - 创建表 - 时间语句

标签 sql datetime ms-access ddl create-table

我在尝试使用 MS Access 创建表时遇到问题。

我确定我的问题出在“日期时间”字段上,但我不知道我遗漏了什么或做错了什么。

当我点击“运行”时,我得到了

"Syntax Error in Field Definition"

Create Table Appointments
(DocID             char(4)             not null       primary key,
 PatID             char(8)             not null,      
 Day               varchar(8)          not null,      
 Time              datetime            not null,
 Procedure         varchar(50)         null);

最佳答案

时间和过程是保留字,因此应该转义:

Create Table Appointments
(DocID             char(4)             not null       primary key,
 PatID             char(8)             not null,      
 [Day]             varchar(8)          not null,      
 [Time]            datetime            not null,
 [Procedure]       varchar(50)         null); 

或者更好的是,查找不是保留字的名称:

Create Table Appointments
(DocID             char(4)             not null       primary key,
 PatID             char(8)             not null,      
 AppointmentDay    varchar(8)          not null,      
 AppointmentTime   datetime            not null,
 MedicalProcedure  varchar(50)         null);

关于sql - 创建表 - 时间语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30898541/

相关文章:

sql - 通过Microsoft Access创建表DDL

sql - django 中的全外连接

mysql - 复制到自动增量更改表的 tmp 表

r - 如何将日期-T-时间转换为日期?

javascript - 使用 JavaScript 根据星期几更改消息?

excel - Access : How To See If An Options Radio Button Is Checked

php - PHP 中的 @SET (SQL)

sql - SQL Server 2016 上插入或更新的安全解决方案

django - django dateTime 的正确格式是什么?

ruby-on-rails - 将 Rails 应用程序连接到 Microsoft Access