Oracle时间型数据的insert语句
insert into Table_A(name,AddTime) values(
insert into Table_A(name,AddTime) values('A5db09',to_date('2004-9-13 17:47:34','yyyy-mm-dd hh:mm:ss')------------------------------------------------------------Oracle中date类型字段的处理
——ORACLE/JSP技术涉及日期、时间问题的处理
(1)在英文版本的ORACLE中默认日期格式为'DD-MON-YY',例如'01-JAN-98'
在汉化的中文版本中ORACLE默认日期格式为'日-月-年',例如'21-8月-2003'或'21-8月-03'
(2)转换字符串为日期
使用ORACLE内部函数to_date()
to_date()函数的参数是to_char()函数参数的反转。
to_date(string_value , date_format)
变量定义如下:
string_value :为字符串直接值(字符串本身)、字符串列(数据库中定义的某个表的某列)或某字符串内部函数的返回值。
date_format为合法的Oracle日期格式。
下列更新语句均符合ORACLE的日期格式,更新成功:
create table student (name varchar2(10) not null primary key , enrolldate date not null);//创建student表
insert into student values('mark',to_date('08-21-2003','MM-DD-YYYY'));
insert into student values('mark1',to_date('21-08-2003','DD-MM-YYYY'));
insert into student values('mark2','21-8月-2003');
insert into xiongxiaomin.student values('mark3','21-8月-03');
(3)转换日期为字符串
使用ORACLE内部函数to_char()
to_char(date_value,date_format)
变量定义如下:
date_value :为日期型直接值(日期本身)、日期型列值(数据库中定义的某个表的某列)或某内部函数的返回的日期型值。
date_format为合法的Oracle日期格式。
选择enrolldate字段的时间部分:
select (to_char(enrolldate,'HH24:MI:SS'))enrolldate from student;
(4)注意:ORACLE中的date数据类型定义的列包含日期和时间。
1、系统当前日期为2003年8月21日,之后执行下列语句
insert into student values('mark5',to_date('09:28:03','HH:MI:SS'));//注意此种在一条记录的date类型字段中插入时间的方法,系统默认的日期为系统当前日期所在月份的第一天,因此得到的记录为
Name enrolldate
-----------------------------------
mark5 01-八月 -2003 09:28:03 AM
2、修改系统当前日期为2003年7月21日,之后执行下列语句
insert into student values('mark6',to_date('09:28:03','HH:MI:SS'));
得到的记录为
Name enrolldate
-----------------------------------
mark6 01-七月 -2003 09:28:03 AM
insert into student values('mark8',to_date('20:28:03','HH24:MI:SS'));

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

Oracle views can be exported through the EXP utility: Log in to the Oracle database. Start the EXP utility, specifying the view name and export directory. Enter export parameters, including target mode, file format, and tablespace. Start exporting. Verify the export using the impdp utility.

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.
