SQL Server GETDATE() 函数
SQL 教程
· 2019-03-04 13:57:42
定义和用法
GETDATE() 函数从 SQL Server 返回当前的日期和时间。
语法
GETDATE()
实例
下面是 SELECT 语句:
SELECT GETDATE() AS CurrentDateTime
结果如下所示:
| CurrentDateTime |
|---|
| 2008-11-11 12:45:34.243 |
注释:上面的时间部分精确到毫秒。
实例
下面的 SQL 创建带有日期时间列(OrderDate)的 "Orders" 表:
CREATE TABLE Orders
(
OrderId int NOT NULL PRIMARY KEY,
ProductName varchar(50) NOT NULL,
OrderDate datetime NOT NULL DEFAULT GETDATE()
)
请注意,OrderDate 列规定 CURDATE() 作为默认值。作为结果,当您向表中插入行时,当前日期和时间自动插入列中。
现在,我们想要在 "Orders" 表中插入一条记录:
INSERT INTO Orders (ProductName) VALUES ('Jarlsberg Cheese')
"Orders" 表将如下所示:
| OrderId | ProductName | OrderDate |
|---|---|---|
| 1 | Jarlsberg Cheese | 2008-11-11 13:23:44.657 |
点击查看所有 SQL 教程 文章: https://codercto.com/courses/l/29.html
Algorithms to Live By
Brian Christian、Tom Griffiths / Henry Holt and Co. / 2016-4-19 / USD 30.00
A fascinating exploration of how insights from computer algorithms can be applied to our everyday lives, helping to solve common decision-making problems and illuminate the workings of the human mind ......一起来看看 《Algorithms to Live By》 这本书的介绍吧!
HEX CMYK 转换工具
HEX CMYK 互转工具
HEX HSV 转换工具
HEX HSV 互换工具