使用 Oracle SQL*PLus 插入格式化日期函数?
我是 Oracle PL/SQL 新手。基本上,我创建了一个表,如下所示:
CREATE TABLE MYTABLE (
ID VARCHAR2(3 CHAR) NOT NULL PRIMARY KEY,
LAST_UPDATE DATE
);
我正在尝试编写一个将通过 SQL*Plus 命令运行的脚本:
insert into MYTABLE (
id,
last_update)
values (
sys_guid,
--- Date call - what is placed here?
);
我可以做什么来确保插入的日期是正确的日期(插入时),格式为(什么)要调用的函数):
2011 年 10 月 27 日
需要从 SQL*Plus 中执行此脚本(请注意,从 SQL Developer 与 SQL*Plus 运行的 ANSI SQL 和 PL/SQL 之间存在大量不兼容性)。
感谢您花时间阅读本文!
Am a Oracle PL/SQL newbie. Basically, I have a table created as follows:
CREATE TABLE MYTABLE (
ID VARCHAR2(3 CHAR) NOT NULL PRIMARY KEY,
LAST_UPDATE DATE
);
Am trying to write a script which will run through SQL*Plus command:
insert into MYTABLE (
id,
last_update)
values (
sys_guid,
--- Date call - what is placed here?
);
What can I do to insure that the date inserted is the correct date (at time of insertion) with this format (what function to call):
27-Oct-11
Will need this script to be executable from within SQL*Plus (read that there's numerous amounts of incompatibilities between ANSI SQL & PL/SQL running from SQL Developer vs. SQL*Plus).
Thanks for taking the time to read this!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
日期字段没有格式。当您使用 to_char 函数选择它们时,您就应用了一种格式。所以你想做的是
你可以使用它从中选择
Date fields don't have a format. You apply a format when you select them by using the to_char function. So what you want to do is
And you select from it using