• 关于 jsp表格修改 的搜索结果

问题

jsp文本框传值中文乱码什么原因?

落地花开啦 2019-12-01 19:30:00 968 浏览量 回答数 1

问题

请问一个可配置的web表格 要如何设计 :报错

kun坤 2020-06-20 13:24:23 1 浏览量 回答数 1

问题

请问一个可配置的web表格 要如何设计 配置报错 

kun坤 2020-05-30 23:29:55 0 浏览量 回答数 1

新用户福利专场,云服务器ECS低至96.9元/年

新用户福利专场,云服务器ECS低至96.9元/年

问题

OA系统买JAVA开发的还是PHP开发?

zhuzailin 2019-12-01 20:54:52 9231 浏览量 回答数 1

问题

使用 Spring 3 来创建 RESTful Web Services 400 请求报错 

kun坤 2020-05-30 22:56:53 1 浏览量 回答数 1

问题

java 进销存 crm websocket即时聊天发图片文字 好友群组 SSM源码

游客ydre72cd7ywew 2019-12-01 19:53:21 40 浏览量 回答数 0

问题

程序员报错行为大赏-配置报错

问问小秘 2020-06-11 13:18:25 6 浏览量 回答数 1

问题

Activiti 工作流项目源码 代码生成器 websocket即时通讯 springmvc SS

游客egqjd4t7mlyom 2019-12-01 19:54:26 50 浏览量 回答数 0

问题

Activiti6.0 java项目框架 spring5 SSM 工作流引擎 审批流程

游客ydre72cd7ywew 2019-12-01 20:01:08 10 浏览量 回答数 0

问题

Activiti6.0 java项目框架 spring5 SSM 工作流引擎 审批流程

游客q6uipubrszn5g 2019-12-01 19:59:18 27 浏览量 回答数 0

问题

Activiti6.0 java项目框架 spring5 SSM 工作流引擎 审批流程

游客ydre72cd7ywew 2019-12-01 19:53:06 30 浏览量 回答数 0

问题

Activiti6.0 工作流引擎 websocket即时聊天发图片文字 好友群组 SSM源码

游客q6uipubrszn5g 2019-12-01 19:57:13 37 浏览量 回答数 0

问题

【精品问答】Java技术1000问(1)

问问小秘 2019-12-01 21:57:43 34170 浏览量 回答数 10

回答

这个html编辑器不用你自己实现吧。它说白了就是个文本框。比如你输入hello,存入数据库就是hello,你把颜色变成红色,就是相当于输入了<font color=red>hello</font>你的程序不需要变动。只是存到数据库表中的内容变长了。多了些html标签而已。。######回复 @uniquesql 那么怎么讲这个设置的样式 如<font size="3" >测试〈/font>保存呢? 在哪里保存呢? 找不到啊?######你想多了。比如在JSP页面上直接取出来就行了 <%=blog.getContent()%>。。 或者EL表达式 ${blog.content} 浏览器会自动渲染这些html标记。。######回复 @追逐梦想 : 就当字符串一样读取即可,不用考虑太多######那么前台是怎么读取的呢? 这个是个值啊,怎么会反映到页面上呢?######文字内容保存的是html样式的~~~~~~~~~~~~~~######就是将这个页面中的设置样式一起保存了吧,然后就是怎么讲保存的样式反应到页面上呢?######你发的这个是。。。。 phpweb 生成的企业站 后台的吧 ######@追逐梦想 哦,呵呵。可能我猜错了######呃,好像不是啊,就是一个网站的后台,有个Html编辑器######归结到底,数据都放到database即可!修改数据库!page取得就是数据库数据!######回复 @Beyond-Bit : 谢谢!######@追逐梦想 设计复杂的,不是一般的难!你简单点,就是把你想变得东西放到数据库,比如:背景颜色你可以放到数据!要修改的时候后台读取,修改!save数据库!页面加载读取数据库即可!######嗯,这个我明白了,但是我不知道怎么讲数据放到数据库中啊。###### <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@ taglib uri="/struts-tags" prefix="s"%> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta content="IE=7.0000" http-equiv="X-UA-Compatible"> <title></title> <link rel="stylesheet" type="text/css" href="css/style(2).css"> <script type="text/javascript" src="js/base(2).js"></script> <script type="text/javascript" src="js/page.js"></script> </head> <body marginheight="0"> <s:iterator value="companyInfo" var="companyInfo"> <form id="modiPageForm" enctype="multipart/form-data" method="post" name="form" action="companyInfoAction_findCompanyInfoById?companyInfoId=<s:property value="#companyInfo.companyInfoId"/>"> <div class="formzone"> <div class="namezone">网页内容编辑</div> <div class="tablezone"> <table style="BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="2" width="100%" align="center" border="0"> <tbody> <tr> <td height="30" align="center">自定序号</td> <td height="30"><input class="input" style="WIDTH: 25px" maxlength="9" value="<s:property value="#companyInfo.companyInfoId"/>" name="companyInfo.companyInfoId"> </td> </tr> <tr> <td height="30" align="center">网页分组</td> <td height="30"><select id="groupid" name="companyInfo.webPageGroup"> <s:if test="#companyInfo.webPageGroup==1"> <option selected="true" value="1">公司简介</option> <option value="22">联系我们</option> </s:if> <s:else> <option value="1">公司简介</option> <option selected="true" value="22">联系我们</option> </s:else> </select></td> </tr> <tr> <td height="30" align="center">排版方式</td> <td height="30"><select id="modiselmodle" name="companyInfo.typeSetMethod"> <s:if test="#companyInfo.typeSetMethod==1"> <option selected="true" value="1">独立自定义排版</option> <option value="0">共享分组的排版</option> </s:if> <s:else> <option value="1">独立自定义排版</option> <option selected="true" value="0">共享分组的排版</option> </s:else> </select> </td> </tr> <tr id="tr_fold"> <td height="30" align="center">网页文件</td> <td height="30"><input id="pagefolder" class="input" maxlength="30" value="<s:property value="#companyInfo.webPageDocument"/>" name="companyInfo.webPageDocument"> .PHP</td> </tr> <tr> <td height="30" width="100" align="center">网页标题</td> <td height="30"><input id="title" class="input" maxlength="200" size="36" value="<s:property value="#companyInfo.webPageTitle"/>" name="companyInfo.webPageTitle"> <font color="#ff0000">*</font> </td> </tr> <tr> <td height="30" align="center">主题图片</td> <td height="30"><input id="jpg" class="input" size="50" type="file" name="jpg"></td> </tr> <tr> <td height="30" width="100" align="center">网页内容</td> <td height="30"><input type="hidden" value="<s:property value="#companyInfo.webPageContent"/>" name="body"> <script type="text/javascript" src="js/KindEditor.js"></script> <script type="text/javascript"> var editor = new KindEditor("editor"); editor.hiddenName = "body"; editor.editorWidth = "700px"; editor.editorHeight = "350px"; editor.skinPath = "img/"; editor.uploadPath = "../../kedit/upload_cgi/upload.php"; editor.imageAttachPath="page/pics/"; editor.iconPath = "img/"; editor.show(); function KindSubmit() { editor.data(); } </script> <div style="font-family:Courier New;"> <div style="width:700px;;border:1px solid #DDDDDD;background-color:#EFEFEF"> <table cellpadding="0" cellspacing="0" border="0" height="26"> <tbody> <tr> <td style="padding:2px;"><img id="KE_SOURCE" src="img/source.gif" alt="视图转换" title="视图转换" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_SOURCE');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_PREVIEW" src="img/preview.gif" alt="预览" title="预览" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_PREVIEW');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_ZOOM" src="img/zoom.gif" alt="显示比例" title="显示比例" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_ZOOM');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_PRINT" src="img/print.gif" alt="打印" title="打印" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_PRINT');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_UNDO" src="img/undo.gif" alt="回退" title="回退" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_UNDO');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_REDO" src="img/redo.gif" alt="前进" title="前进" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_REDO');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_CUT" src="img/cut.gif" alt="剪切" title="剪切" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_CUT');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_COPY" src="img/copy.gif" alt="复制" title="复制" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_COPY');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_PASTE" src="img/paste.gif" alt="粘贴" title="粘贴" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_PASTE');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_SELECTALL" src="img/selectall.gif" alt="全选" title="全选" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_SELECTALL');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_JUSTIFYLEFT" src="img/justifyleft.gif" alt="左对齐" title="左对齐" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_JUSTIFYLEFT');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_JUSTIFYCENTER" src="img/justifycenter.gif" alt="居中" title="居中" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_JUSTIFYCENTER');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_JUSTIFYRIGHT" src="img/justifyright.gif" alt="右对齐" title="右对齐" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_JUSTIFYRIGHT');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_JUSTIFYFULL" src="img/justifyfull.gif" alt="两端对齐" title="两端对齐" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_JUSTIFYFULL');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_NUMBEREDLIST" src="img/numberedlist.gif" alt="编号" title="编号" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_NUMBEREDLIST');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_UNORDERLIST" src="img/unorderedlist.gif" alt="项目符号" title="项目符号" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_UNORDERLIST');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_INDENT" src="img/indent.gif" alt="减少缩进" title="减少缩进" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_INDENT');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_OUTDENT" src="img/outdent.gif" alt="增加缩进" title="增加缩进" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_OUTDENT');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_SUBSCRIPT" src="img/subscript.gif" alt="下标" title="下标" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_SUBSCRIPT');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_SUPERSCRIPT" src="img/superscript.gif" alt="上标" title="上标" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_SUPERSCRIPT');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_DATE" src="img/date.gif" alt="日期" title="日期" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_DATE');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_TIME" src="img/time.gif" alt="时间" title="时间" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_TIME');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> </tr> </tbody> </table> <table cellpadding="0" cellspacing="0" border="0" height="26"> <tbody> <tr> <td style="padding:2px;"><img id="KE_TITLE" src="img/title.gif" alt="标题" title="标题" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_TITLE');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_FONTNAME" src="img/font.gif" alt="字体" title="字体" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_FONTNAME');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_FONTSIZE" src="img/fontsize.gif" alt="文字大小" title="文字大小" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_FONTSIZE');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_TEXTCOLOR" src="img/textcolor.gif" alt="文字颜色" title="文字颜色" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_TEXTCOLOR');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_BGCOLOR" src="img/bgcolor.gif" alt="文字背景" title="文字背景" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_BGCOLOR');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_BOLD" src="img/bold.gif" alt="粗体" title="粗体" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_BOLD');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_ITALIC" src="img/italic.gif" alt="斜体" title="斜体" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_ITALIC');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_UNDERLINE" src="img/underline.gif" alt="下划线" title="下划线" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_UNDERLINE');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_STRIKE" src="img/strikethrough.gif" alt="删除线" title="删除线" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_STRIKE');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_REMOVE" src="img/removeformat.gif" alt="删除格式" title="删除格式" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_REMOVE');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_IMAGE" src="img/image.gif" alt="图片" title="图片" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_IMAGE');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_FLASH" src="img/flash.gif" alt="Flash" title="Flash" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_FLASH');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_MEDIA" src="img/media.gif" alt="Windows Media Player" title="Windows Media Player" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_MEDIA');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_REAL" src="img/real.gif" alt="Real Player" title="Real Player" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_REAL');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_LAYER" src="img/layer.gif" alt="层" title="层" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_LAYER');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_TABLE" src="img/table.gif" alt="表格" title="表格" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_TABLE');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_SPECIALCHAR" src="img/specialchar.gif" alt="特殊字符" title="特殊字符" align="absmiddle" style="border: 1px solid rgb(239, 239, 239); cursor: pointer; height: 20px;" onclick="javascript:KindExecute('KE_SPECIALCHAR');" onmouseover="javascript:this.style.border='1px solid #AAAAAA';" onmouseout="javascript:this.style.border='1px solid #EFEFEF';"> </td> <td style="padding:2px;"><img id="KE_HR" src="img/hr.gif" alt="横线" title="横线" align="absmiddle" style="border:1px solid #EFEFEF;cursor:pointer;height:20px;" onclick="javascript:KindExecute('KE_HR');" onmo

kun坤 2020-06-06 23:47:11 0 浏览量 回答数 0

回答

---数据库版本 select * from v$version ---SCOTT默认表空间以及用户 select u.username,u.default_tablespace from dba_users u where u.username='SCOTT' select * from database_properties dp where dp.property_name='DEFAULT_PERMANENT_TABLESPACE'; select u.username,u.default_tablespace from dba_users u where u.username='dborcl' select * from dba_tablespaces ---1.首先,创建(新)用户: create user gaohao identified by gaohao; --也可以不创建新用户,而仍然用以前的用户,如:继续利用scott用户 ---2.创建表空间: create tablespace ZTTM datafile 'd:\oracle\data.dbf' size 500M; ---3.将空间分配给用户: alter user gaohao default tablespace ZTTM; ---将名字为tablespacename的表空间分配给username ---4.给用户授权: grant create session,create table,unlimited tablespace to gaohao; ---5.然后再以楼主自己创建的用户登录,登录之后创建表即可。 create user ZTTM identified by zttm; alter user ZTTM default tablespace ZTTM; grant create session,create table,unlimited tablespace to ZTTM; ---建表 create table UserInfo ( USERID int primary key , UNAME varchar(20) not null, ISMARRAY char(5) not null, ISONJOB char(5) not null, REMARK varchar(500) null ) insert into UserInfo values(1,'Tom','0','0','*****************************'); insert into UserInfo values(2,'JACK','1','0','JJJJJJJJJJJJJJJJJJJJJJJJJ'); insert into UserInfo values(3,'JIM','0','1','WWWWWWWWWWWWWWW'); insert into UserInfo values(4,'BOT','1','1','AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); insert into UserInfo values(5,'KATE','1','0','GGGGGGGGGGGGGGGGGGGGGGGG'); insert into UserInfo values(6,'BRAN','0','1','HHHHHHHHHHHHHHHHHHHHHHHHHHHHH'); insert into UserInfo values(7,'JUN','1','1','RRRRRRRRRRRRRRRRRRRRRRRRRRR'); insert into UserInfo values(8,'ANDRUE','1','1','EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE'); insert into UserInfo values(9,'ALICE','1','0','VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV'); insert into UserInfo values(10,'HANKS','0','1','QQQQQQQQQQQQQQQQQQQQQQQQQQQQQ'); insert into UserInfo values(11,'KEBE','0','1','BNNNNNNNNNNNNNNNNNNNNNNNN'); insert into UserInfo values(12,'SAM','1','0','ZXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); insert into UserInfo values(13,'BOB','0','0','TTTTTTTTTTTTTTTTTTTTTTTTTTTT'); select * from UserInfo; select to_date('20120725115536','yyyy-MM-dd HH24:mi:ss') TimeStamp from dual grant select on v_$statname to gaohao; grant select on v_$session to gaohao; grant select on v_$sesstat to gaohao; grant select on v_$mystat to gaohao; grant select on v_$statname to ZTTM; grant select on v_$session to ZTTM; grant select on v_$sesstat to ZTTM; grant select on v_$mystat to ZTTM; select u.USERID,--员工编号 u.UNAME, --员工姓名 u.ISMARRAY, --婚否 u.ISONJOB,--是否在职 u.REMARK --备注 from UserInfo u where u.USERID like '%1%' select to_char(to_date('20120727094755','yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss') CurrentTime from dual select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') CurrentTime from dual; select TO_DATE(null) from dual; /SQL语句/ select * from log_cpuidle where idle_date = (select to_char(sysdate-1,'DD-MON-YY') from dual); /*其中idle_date是DATE类型的,不知道为啥要将sysdate进行转换,只有这样才能查找到日期是前一天的数据; 其中要注意的是sysdate对应的格式为DD-MON-YY;*/ insert into table select a, b, count()c,avg(d),e from LOG_TABLE where a=(select to_char(sysdate-1, 'DD-MON-YY') from dual) group by a, b, e order by b; / 复合型的insert 语句; 取前几行的数据用rownum;select * from table where rownum < 10; group by:分组查询,一般和聚合函数(AVG、SUM、MAX、COUNT等)一起使用,它后面可以跟having限制性语句; order by:select “栏位名” from “表格”[where “条件”] order by “栏位名”[asc, desc]*/ •/============创建Customer表==========/ •create table Customer •( • Customer_id number(6) not null, • Customer_name varchar2(50) not null, • Password varchar2(20) not null, • True_name varchar2(20), • Email_address varchar2(50) not null, --唯一 • Password_question varchar2(50) not null, • Password_anwser varchar2(50) not null, • Status char(1), --默认是1,取值0或1 • Customer_level char(1), --默认是1,取值1,2,3 • Score number(6), • Register_date date, --默认为系统时间 • Login_time timestamp, • Login_count number(6), • Login_ip char(6) •); •/===========创建Orders表==========/ •create table Orders •( • Order_id varchar2(10) not null, • Order_Customer_id number(6) not null, • Order_date date not null, • Order_price number not null •); •/==========查询Customer表===========/ •select * from Customer • •/==========向表中添加数据===========/ •insert into Customer values •(220077,'wantingqiang','wtq','万廷强','lovezhqj@qq.com','你是哪个?','wtq','1','3',150,sysdate,sysdate,15789,'172.26') • •/==========修改表Customer===========/ •alter table Customer •modify Login_ip char(16); • •/=========修改第一条记录中的ip=====/ •update Customer set Login_ip='172.26.3.145' where Customer_id='220077';--ip地址修改成功 • •/=========添加一个列===============/ •alter table Customer •add LoginOut_time date; --新列增加成功 • •/=========删除一个列LoginOut_time========/ •alter table Customer •drop column LoginOut_time; --列删除成功 • •/========给列添加注释===========/ •comment on column • Customer.Customer_Name is '客户姓名'; • •/========给表添加注释==========/ •comment on table Customer is '客户表,为了保持与客户的联系'; • •/========重新命名表============/ •alter table Customer rename to Customer_Change; • •select * from Customer_Change • •alter table Customer_Change rename to Customer; • •/==========添加非空约束========/ •alter table Customer •modify status not null; --非空约束添加成功 • •/==========添加主键约束========/ •alter table Customer •add constraint customer_id_pk primary key(Customer_id); --主键添加成功 • •/==========添加外键约束========/ •--向Orders表中添加外键,与Customer表关联 •--在下面的列子末尾加上: •--on delete 表示允许级联删除 •--on update 表示允许级联更新 •alter table Orders •add constraint Orders_Customer_fk foreign key(Order_Customer_id) references Customer(Customer_id); •--外键添加成功 •/==========删除外键约束=========/ •alter table Orders •drop constraint "ORDERS_CUSTOMER_FK"; --外键删除成功,这个要注意大小写哈 • •/=========添加唯一约束========/ •alter table Customer •add constraint un_email unique(Email_address); --添加唯一约束成功 • • •/=========修改默认约束========/ •alter table Customer •modify Status default('1'); • •/=========添加检查约束========/ •alter table Customer •add constraint ck_status check(Status in ('1','0')); --检查约束添加成功 • • •/==========禁止检查约束=======/ •alter table Customer • disable constraint ck_status; --禁止成功 • •/==========激活检查约束=======/ •alter table Customer • enable constraint ck_status; --激活成功 • •/==========删除检查约束========/ •alter table Customer •drop constraint ck_status; --删除检查约束成功 • •/==========最后是删除表========/ •drop table Customer; --删除表成功 /使用SQLPLUS(1) SQL> desc table; 显示表结构 SQL> select * from tab; 查看用户下所有的表 SQL> set pause on; 可以使大量结果集在用户按“Enter”(回车)后翻页 SQL> set pagesize 100; 设定SQL语句返回结果集一页的行数100, 默认值是14 SQL> set linesize 100; 设定SQL语句返回结果集一行的宽度100, 默认值是80*/ /*常用的日期处理函数 oracle内部以数字格式存储日期和时间信息:世纪,年,月,日,小时,分钟,秒 临时表dual表 缺省格式:DD-MON-YY('14-3月-08') round(to_date('14-3月-08'),'month') 可使用sysdate函数(没有参数和括号)获取当前系统日期和时间 日期数据直接加或减一个数值(不一定是整数,代表的是多少天),结果仍为日期(约定的单位为天,当然也可以为月或年) 两个日期数据可以相减(不可相加,没有意义 ),结果为二者相差多少天 add_months(日期x,数值y):计算在日期x基础上增加y个月后的日期 add_months(sysdate,2) last_day(s) 返回日期x当月最后一天的日期 last_day(sysdate) months_between(x,y) 返回日期x和y之间相差的月数 months_between(sysdate,sysdate) 有正负号之分(参数前后关系有关) round(x,y) 四舍五入将日期x截断到y所指定的日期单位(月或年)的第一天 round(sysdate,'month') 3月14号为3月1号 3月16号为4月1号 年的同理round(sysdate,'year') trunc(x,y) 将日期x截断到y所指定的日期单位(月或年)的第一天,不四舍五入trunc(sysdate,'month')trunc(sysdate,'year') next_day(x,y) 计算指定日期x后的第一个星期几(由参数y指定)对应的日期 next_day(sysdate,'星期二')*/ select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as nowTime from dual; //日期转化为字符串 select to_char(sysdate,'yyyy') as nowYear from dual; //获取时间的年 select to_char(sysdate,'mm') as nowMonth from dual; //获取时间的月 select to_char(sysdate,'dd') as nowDay from dual; //获取时间的日 select to_char(sysdate,'hh24') as nowHour from dual; //获取时间的时 select to_char(sysdate,'mi') as nowMinute from dual; //获取时间的分 select to_char(sysdate,'ss') as nowSecond from dual; //获取时间的秒 select floor(sysdate - to_date('20020405','yyyymmdd')) from dual; /设置两个日期之间的天数;/ select count(*)from ( select rownum-1 rnum from all_objects where rownum <= to_date('2002-02-28','yyyy-mm-dd') - to_date('2002-02-01','yyyy-mm-dd')+1 ) where to_char( to_date('2002-02-01','yyyy-mm-dd')+rnum-1, 'D' ) not in ( '1', '7' ) select TO_CHAR(SYSDATE,'DDD'),sysdate from dual /显示今天是一年中的第几天;/ /计算时间差 注:oracle时间差是以天数为单位,所以换算成年月,日 select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))/365) as spanYears from dual // 时间差-年 select ceil(moths_between(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))) as spanMonths from dual //时间差-月 select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))) as spanDays from dual //时 间差-天 select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))24) as spanHours from dual // 时间差-时 select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))2460) as spanMinutes from dual //时间差-分 select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))246060) as spanSeconds from dual //时间差-秒/ /TO_DATE格式(以时间:2007-11-02 13:45:25为例) Year: yy two digits 两位年 显示值:07 yyy three digits 三位年 显示值:007 yyyy four digits 四位年 显示值:2007 Month: mm number 两位月 显示值:11 mon abbreviated 字符集表示 显示值:11月,若是英文版,显示nov month spelled out 字符集表示 显示值:11月,若是英文版,显示november Day: dd number 当月第几天 显示值:02 ddd number 当年第几天 显示值:02 dy abbreviated 当周第几天简写 显示值:星期五,若是英文版,显示fri day spelled out 当周第几天全写 显示值:星期五,若是英文版,显示friday ddspth spelled out, ordinal twelfth/ /日期的比较/ /在今天之前:/ select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') select * from up_date where update <= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') /在今天只后:/ select * from up_date where update > to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') select * from up_date where update >= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') /精确时间:/ select * from up_date where update = to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') /在某段时间内:/ select * from up_date where update between to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') select * from up_date where update < to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and update > to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss') select * from up_date where update <= to_date('2007-09-07 00:00:00','yyyy-mm-dd hh24:mi:ss') and update >= to_date('2007-07-07 00:00:00','yyyy-mm-dd hh24:mi:ss') /日期时间间隔操作/   /*当前时间减去7分钟的时间 */  select sysdate,sysdate - interval '7' MINUTE from dual /*当前时间减去7小时的时间 */  select sysdate - interval '7' hour from dual /*当前时间减去7天的时间 */  select sysdate - interval '7' day from dual /当前时间减去7月的时间/ select sysdate,sysdate - interval '7' month from dual /当前时间减去7年的时间/ select sysdate,sysdate - interval '7' year from dual /时间间隔乘以一个数字/ select sysdate,sysdate - 8 *interval '2' hour from dual /返回当前时间 年月日小时分秒毫秒/   select to_char(current_timestamp(5),'DD-MON-YYYY HH24:MI:SSxFF') from dual; --返回当前 时间的秒毫秒,可以指定秒后面的精度(最大=9)   select to_char(current_timestamp(9),'MI:SSxFF') from dual; /Oracle SQL 语句对时间操作的总结/ /在SQL语句中,常常用会对时间(或日期)进行一些处理,下面是比较通用的一些语句: 延迟: sysdate+(5/24/60/60) 在系统时间基础上延迟5秒 sysdate+5/24/60 在系统时间基础上延迟5分钟 sysdate+5/24 在系统时间基础上延迟5小时 sysdate+5 在系统时间基础上延迟5天 add_months(sysdate,-5) 在系统时间基础上延迟5月 add_months(sysdate,-512) 在系统时间基础上延迟5年 */ /上月末的日期:/ select last_day(add_months(sysdate, -1)) from dual; /本月的最后一秒:/ select trunc(add_months(sysdate,1),'MM') - 1/24/60/60 from dual /本周星期一的日期:/ select trunc(sysdate,'day')+1 from dual /年初至今的天数:/ select ceil(sysdate - trunc(sysdate, 'year')) from dual; /今天是今年的第几周 :/ select to_char(sysdate,'fmww') from dual /今天是本月的第几周:/ SELECT TO_CHAR(SYSDATE,'WW') - TO_CHAR(TRUNC(SYSDATE,'MM'),'WW') + 1 AS "weekOfMon" FROM dual /本月的天数/ SELECT to_char(last_day(SYSDATE),'dd') days FROM dual /今年的天数/ select add_months(trunc(sysdate,'year'), 12) - trunc(sysdate,'year') from dual /下个星期一的日期/ SELECT Next_day(trunc(SYSDATE),'monday') FROM dual ================================ /计算工作日方法/ create table t(s date,e date); alter session set nls_date_format = 'yyyy-mm-dd'; insert into t values('2003-03-01','2003-03-03'); insert into t values('2003-03-02','2003-03-03'); insert into t values('2003-03-07','2003-03-08'); insert into t values('2003-03-07','2003-03-09'); insert into t values('2003-03-05','2003-03-07'); insert into t values('2003-02-01','2003-03-31'); -- 这里假定日期都是不带时间的,否则在所有日期前加trunc即可。 select s,e,e-s+1 total_days, trunc((e-s+1)/7)*5 + length(replace(substr('01111100111110',to_char(s,'d'),mod(e-s+1,7)),'0','')) work_days from t; -- drop table t; ======================================================== /判断当前时间是上午下午还是晚上/ SELECT CASE WHEN to_number(to_char(SYSDATE,'hh24')) BETWEEN 6 AND 11 THEN '上午' WHEN to_number(to_char(SYSDATE,'hh24')) BETWEEN 11 AND 17 THEN '下午' WHEN to_number(to_char(SYSDATE,'hh24')) BETWEEN 17 AND 21 THEN '晚上' END FROM dual; ========================================================== /Oracle 中的一些处理日期/ /将数字转换为任意时间格式.如秒:需要转换为天/小时/ SELECT to_char(floor(TRUNC(936000/(6060))/24))||'天'||to_char(mod(TRUNC(936000/(6060)),24))||'小时' FROM DUAL TO_DATE格式 /*Day: dd number 12 dy abbreviated fri day spelled out friday ddspth spelled out, ordinal twelfth Month: mm number 03 mon abbreviated mar month spelled out march Year: yy two digits 98 yyyy four digits 1998 24小时格式下时间范围为: 0:00:00 - 23:59:59.... 12小时格式下时间范围为: 1:00:00 - 12:59:59 .... 日期和字符转换函数 用法(to_date,to_char) */ 2. select to_char( to_date(222,'J'),'Jsp') from dual /*显示Two Hundred Twenty-Two */ /*3. 求某天是星期几 */ select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day') from dual; select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual; /设置日期语言/ ALTER SESSION SET NLS_DATE_LANGUAGE='AMERICAN'; /*也可以这样 */ TO_DATE ('2002-08-26', 'YYYY-mm-dd', 'NLS_DATE_LANGUAGE = American') /*4. 两个日期间的天数 */ select floor(sysdate - to_date('20020405','yyyymmdd')) from dual; /*5. 时间为null的用法 */ select id, active_date from table1 UNION select 1, TO_DATE(null) from dual; /注意要用TO_DATE(null)/ /*6. a_date between to_date('20011201','yyyymmdd') and to_date('20011231','yyyymmdd') 那么12月31号中午12点之后和12月1号的12点之前是不包含在这个范围之内的。 所以,当时间需要精确的时候,觉得to_char还是必要的 日期格式冲突问题 输入的格式要看你安装的ORACLE字符集的类型, 比如: US7ASCII, date格式的类型就是: '01-Jan-01' */ alter system set NLS_DATE_LANGUAGE = American alter session set NLS_DATE_LANGUAGE = American /*或者在to_date中写 */ select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual; /注意我这只是举了NLS_DATE_LANGUAGE,当然还有很多, 可查看/ select * from nls_session_parameters select * from V$NLS_PARAMETERS 8. select count(*) from ( select rownum-1 rnum from all_objects where rownum <= to_date('2002-02-28','yyyy-mm-dd') - to_date('2002- 02-01','yyyy-mm-dd')+1 ) where to_char( to_date('2002-02-01','yyyy-mm-dd')+rnum-1, 'D' ) not in ( '1', '7' ) /*查找2002-02-28至2002-02-01间除星期一和七的天数 在前后分别调用DBMS_UTILITY.GET_TIME, 然后将结果相减(得到的是1/100秒, 而不是毫秒). */ 9. select months_between(to_date('01-31-1999','MM-DD-YYYY'), to_date('12-31-1998','MM-DD-YYYY')) "MONTHS" FROM DUAL; 1 select months_between(to_date('02-01-1999','MM-DD-YYYY'), to_date('12-31-1998','MM-DD-YYYY')) "MONTHS" FROM DUAL; 1.03225806451613 /*10. Next_day的用法 Next_day(date, day) */ /*Monday-Sunday, for format code DAY Mon-Sun, for format code DY 1-7, for format code D */ 11 select to_char(sysdate,'hh:mi:ss') TIME from all_objects /*注意:第一条记录的TIME 与最后一行是一样的 可以建立一个函数来处理这个问题 */ create or replace function sys_date return date is begin return sysdate; end; select to_char(sys_date,'hh:mi:ss') from all_objects; /*12. 获得小时数 */ SQL> select sysdate ,to_char(sysdate,'hh') from dual; SYSDATE TO_CHAR(SYSDATE,'HH') 2003-10-13 19:35:21 07 SQL> select sysdate ,to_char(sysdate,'hh24') from dual; SYSDATE TO_CHAR(SYSDATE,'HH24') 2003-10-13 19:35:21 19 /*获取年月日与此类似 */ /*13. 年月日的处理 / select older_date, newer_date, years, months, abs( trunc( newer_date- add_months( older_date,years12+months ) ) ) days from ( select trunc(months_between( newer_date, older_date )/12) YEARS, mod(trunc(months_between( newer_date, older_date )), 12 ) MONTHS, newer_date, older_date from ( select hiredate older_date, add_months(hiredate,rownum)+rownum newer_date from emp ) ) /*14. 处理月份天数不定的办法 */ select to_char(add_months(last_day(sysdate) +1, -2), 'yyyymmdd'),last_day(sysdate) from dual /*16. 找出今年的天数 */ select add_months(trunc(sysdate,'year'), 12) - trunc(sysdate,'year') from dual /*闰年的处理方法 */ to_char( last_day( to_date('02' | | :year,'mmyyyy') ), 'dd' ) /*如果是28就不是闰年 */ /*17. yyyy与rrrr的区别 / /'YYYY99 TO_C yyyy 99 0099 rrrr 99 1999 yyyy 01 0001 rrrr 01 2001 18.不同时区的处理 */ select to_char( NEW_TIME( sysdate, 'GMT','EST'), 'dd/mm/yyyy hh:mi:ss') ,sysdate from dual; /*19. 5秒钟一个间隔 */ Select TO_DATE(FLOOR(TO_CHAR(sysdate,'SSSSS')/300) * 300,'SSSSS') ,TO_CHAR(sysdate,'SSSSS') from dual TO_DATE(FL TO_CH 2007-01-01 60368 /*SSSSS表示5位秒数 */ /*20. 一年的第几天 */ select TO_CHAR(SYSDATE,'DDD'),sysdate from dual TO_ SYSDATE 017 2007-01-17 /21.计算小时,分,秒,毫秒 / select Days, A, TRUNC(A24) Hours, TRUNC(A2460 - 60TRUNC(A24)) Minutes, TRUNC(A246060 - 60TRUNC(A2460)) Seconds, TRUNC(A246060100 - 100TRUNC(A2460*60)) mSeconds from ( select trunc(sysdate) Days, sysdate - trunc(sysdate) A from dual ) select * from tabname order by decode(mode,'FIFO',1,-1)*to_char(rq,'yyyymmddhh24miss'); /*// floor((date2-date1) /365) 作为年 floor((date2-date1, 365) /30) 作为月 mod(mod(date2-date1, 365), 30) 作为日. */ /*22.next_day函数 */ /*next_day(sysdate,6)是从当前开始下一个星期五。后面的数字是从星期日开始算起。 1 2 3 4 5 6 7 日 一 二 三 四 五 六 */ select (sysdate-to_date('2003-12-03 12:55:45','yyyy-mm-dd hh24:mi:ss'))2460*60 from dual /*日期 返回的是天 然后 转换为ss */ select (sysdate-to_date('2003-12-03 12:55:45','yyyy-mm-dd hh24:mi:ss'))2460 from dual ; select (sysdate-to_date('2003-12-03 12:55:45','yyyy-mm-dd hh24:mi:ss'))*24 from dual ; select (sysdate-to_date('2012-07-23 12:55:45','yyyy-mm-dd hh24:mi:ss'))*24 from dual ; select (sysdate-to_date('2003-12-03 12:55:45','yyyy-mm-dd hh24:mi:ss'))2460*60 from dual ; Oracle中TO_DATE格式 TO_DATE格式(以时间:2007-11-02 13:45:25为例) Year: yy two digits 两位年 显示值:07 yyy three digits 三位年 显示值:007 yyyy four digits 四位年 显示值:2007 Month: mm number 两位月 显示值:11 mon abbreviated 字符集表示 显示值:11月,若是英文版,显示nov month spelled out 字符集表示 显示值:11月,若是英文版,显示november Day: dd number 当月第几天 显示值:02 ddd number 当年第几天 显示值:02 dy abbreviated 当周第几天简写 显示值:星期五,若是英文版,显示fri day spelled out 当周第几天全写 显示值:星期五,若是英文版,显示friday ddspth spelled out, ordinal twelfth Hour: hh two digits 12小时进制 显示值:01 hh24 two digits 24小时进制 显示值:13 Minute: mi two digits 60进制 显示值:45 Second: ss two digits 60进制 显示值:25 其它 Q digit 季度 显示值:4 WW digit 当年第几周 显示值:44 W digit 当月第几周 显示值:1 24小时格式下时间范围为: 0:00:00 - 23:59:59.... 12小时格式下时间范围为: 1:00:00 - 12:59:59 .... 日期和字符转换函数用法(to_date,to_char) select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as nowTime from dual; //日期转化为字符串 select to_char(sysdate,'yyyy') as nowYear from dual; //获取时间的年 select to_char(sysdate,'mm') as nowMonth from dual; //获取时间的月 select to_char(sysdate,'dd') as nowDay from dual; //获取时间的日 select to_char(sysdate,'hh24') as nowHour from dual; //获取时间的时 select to_char(sysdate,'mi') as nowMinute from dual; //获取时间的分 select to_char(sysdate,'ss') as nowSecond from dual; //获取时间的秒 select to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss') from dual// select to_char( to_date(222,'J'),'Jsp') from dual 显示Two Hundred Twenty-Two 3.求某天是星期几 select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day') from dual; 星期一 select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual; monday 设置日期语言 ALTER SESSION SET NLS_DATE_LANGUAGE='AMERICAN'; 也可以这样 TO_DATE ('2002-08-26', 'YYYY-mm-dd', 'NLS_DATE_LANGUAGE = American') 两个日期间的天数 select floor(sysdate - to_date('20020405','yyyymmdd')) from dual; 时间为null的用法 select id, active_date from table1 UNION select 1, TO_DATE(null) from dual; 注意要用TO_DATE(null) 6.月份差 a_date between to_date('20011201','yyyymmdd') and to_date('20011231','yyyymmdd') 那么12月31号中午12点之后和12月1号的12点之前是不包含在这个范围之内的。 所以,当时间需要精确的时候,觉得to_char还是必要的 日期格式冲突问题 输入的格式要看你安装的ORACLE字符集的类型, 比如: US7ASCII, date格式的类型就是: '01-Jan-01' alter system set NLS_DATE_LANGUAGE = American alter session set NLS_DATE_LANGUAGE = American 或者在to_date中写 select to_char(to_date('2002-08-26','yyyy-mm-dd'),'day','NLS_DATE_LANGUAGE = American') from dual; 注意我这只是举了NLS_DATE_LANGUAGE,当然还有很多, 可查看 select * from nls_session_parameters select * from V$NLS_PARAMETERS select count(*) from ( select rownum-1 rnum from all_objects where rownum <= to_date('2002-02-28','yyyy-mm-dd') - to_date('2002- 02-01','yyyy-mm-dd')+1 ) where to_char( to_date('2002-02-01','yyyy-mm-dd')+rnum-1, 'D' ) not in ( '1', '7' ) 查找2002-02-28至2002-02-01间除星期一和七的天数 在前后分别调用DBMS_UTILITY.GET_TIME, 让后将结果相减(得到的是1/100秒, 而不是毫秒). 查找月份 select months_between(to_date('01-31-1999','MM-DD-YYYY'),to_date('12-31-1998','MM-DD-YYYY')) "MONTHS" FROM DUAL; 1 select months_between(to_date('02-01-1999','MM-DD-YYYY'),to_date('12-31-1998','MM-DD-YYYY')) "MONTHS" FROM DUAL; 1.03225806451613 Next_day的用法 Next_day(date, day) Monday-Sunday, for format code DAY Mon-Sun, for format code DY 1-7, for format code D 11 select to_char(sysdate,'hh:mi:ss') TIME from all_objects 注意:第一条记录的TIME 与最后一行是一样的 可以建立一个函数来处理这个问题 create or replace function sys_date return date is begin return sysdate; end; select to_char(sys_date,'hh:mi:ss') from all_objects; 12.获得小时数 extract()找出日期或间隔值的字段值 SELECT EXTRACT(HOUR FROM TIMESTAMP '2001-02-16 2:38:40') from offer SQL> select sysdate ,to_char(sysdate,'hh') from dual; SYSDATE TO_CHAR(SYSDATE,'HH') -------------------- --------------------- 2003-10-13 19:35:21 07 SQL> select sysdate ,to_char(sysdate,'hh24') from dual; SYSDATE TO_CHAR(SYSDATE,'HH24') -------------------- ----------------------- 2003-10-13 19:35:21 19 13.年月日的处理 select older_date, newer_date, years, months, abs( trunc( newer_date- add_months( older_date,years*12+months ) ) ) days from ( select trunc(months_between( newer_date, older_date )/12) YEARS, mod(trunc(months_between( newer_date, older_date )),12 ) MONTHS, newer_date, older_date from ( select hiredate older_date, add_months(hiredate,rownum)+rownum newer_date from emp ) ) 14.处理月份天数不定的办法 select to_char(add_months(last_day(sysdate) +1, -2), 'yyyymmdd'),last_day(sysdate) from dual 16.找出今年的天数 select add_months(trunc(sysdate,'year'), 12) - trunc(sysdate,'year') from dual 闰年的处理方法 to_char( last_day( to_date('02' | | :year,'mmyyyy') ), 'dd' ) 如果是28就不是闰年 17.yyyy与rrrr的区别 'YYYY99 TO_C yyyy 99 0099 rrrr 99 1999 yyyy 01 0001 rrrr 01 2001 18.不同时区的处理 select to_char( NEW_TIME( sysdate, 'GMT','EST'), 'dd/mm/yyyy hh:mi:ss') ,sysdate from dual; 19.5秒钟一个间隔 Select TO_DATE(FLOOR(TO_CHAR(sysdate,'SSSSS')/300) * 300,'SSSSS') ,TO_CHAR(sysdate,'SSSSS') from dual 2002-11-1 9:55:00 35786 SSSSS表示5位秒数 20.一年的第几天 select TO_CHAR(SYSDATE,'DDD'),sysdate from dual 310 2002-11-6 10:03:51 21.计算小时,分,秒,毫秒 select Days, A, TRUNC(A24) Hours, TRUNC(A2460 - 60TRUNC(A24)) Minutes, TRUNC(A246060 - 60TRUNC(A2460)) Seconds, TRUNC(A246060100 - 100TRUNC(A2460*60)) mSeconds from ( select trunc(sysdate) Days, sysdate - trunc(sysdate) A from dual ) select * from tabname order by decode(mode,'FIFO',1,-1)*to_char(rq,'yyyymmddhh24miss'); // floor((date2-date1) /365) 作为年 floor((date2-date1, 365) /30) 作为月 d(mod(date2-date1, 365), 30)作为日. 23.next_day函数 返回下个星期的日期,day为1-7或星期日-星期六,1表示星期日 next_day(sysdate,6)是从当前开始下一个星期五。后面的数字是从星期日开始算起。 1 2 3 4 5 6 7 日 一 二 三 四 五 六 select (sysdate-to_date('2003-12-03 12:55:45','yyyy-mm-dd hh24:mi:ss'))2460*60 from ddual 日期 返回的是天 然后 转换为ss 24,round舍入到最接近的日期 select sysdate S1, round(sysdate) S2 , round(sysdate,'year') YEAR, round(sysdate,'month') MONTH , round(sysdate,'day') DAY from dual 25,trunc[截断到最接近的日期,单位为天] ,返回的是日期类型 select sysdate S1, trunc(sysdate) S2, //返回当前日期,无时分秒 trunc(sysdate,'year') YEAR, //返回当前年的1月1日,无时分秒 trunc(sysdate,'month') MONTH , //返回当前月的1日,无时分秒 trunc(sysdate,'day') DAY //返回当前星期的星期天,无时分秒 from dual 26,返回日期列表中最晚日期 select greatest('01-1月-04','04-1月-04','10-2月-04') from dual 27.计算时间差 注:oracle时间差是以天数为单位,所以换算成年月,日 select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))/365) as spanYears from dual //时间差-年 select ceil(moths_between(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))) as spanMonths from dual //时间差-月 select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))) as spanDays from dual //时间差-天 select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))*24) as spanHours from dual //时间差-时 select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))*24*60) as spanMinutes from dual //时间差-分 select floor(to_number(sysdate-to_date('2007-11-02 15:55:03','yyyy-mm-dd hh24:mi:ss'))*24*60*60) as spanSeconds from dual //时间差-秒 28.更新时间 注:oracle时间加减是以天数为单位,设改变量为n,所以换算成年月,日 select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),to_char(sysdate+n*365,'yyyy-mm-dd hh24:mi:ss') as newTime from dual //改变时间-年 select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),add_months(sysdate,n) as newTime from dual //改变时间-月 select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),to_char(sysdate+n,'yyyy-mm-dd hh24:mi:ss') as newTime from dual //改变时间-日 select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),to_char(sysdate+n/24,'yyyy-mm-dd hh24:mi:ss') as newTime from dual //改变时间-时 select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),to_char(sysdate+n/24/60,'yyyy-mm-dd hh24:mi:ss') as newTime from dual //改变时间-分 select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),to_char(sysdate+n/24/60/60,'yyyy-mm-dd hh24:mi:ss') as newTime from dual //改变时间-秒 29.查找月的第一天,最后一天 SELECT Trunc(Trunc(SYSDATE, 'MONTH') - 1, 'MONTH') First_Day_Last_Month, Trunc(SYSDATE, 'MONTH') - 1 / 86400 Last_Day_Last_Month, Trunc(SYSDATE, 'MONTH') First_Day_Cur_Month, LAST_DAY(Trunc(SYSDATE, 'MONTH')) + 1 - 1 / 86400 Last_Day_Cur_Month FROM dual;

保持可爱mmm 2020-04-15 23:33:10 0 浏览量 回答数 0
阿里云大学 云服务器ECS com域名 网站域名whois查询 开发者平台 小程序定制 小程序开发 国内短信套餐包 开发者技术与产品 云数据库 图像识别 开发者问答 阿里云建站 阿里云备案 云市场 万网 阿里云帮助文档 免费套餐 开发者工具 云栖号物联网 小程序开发制作 视频内容分析 企业网站制作 视频集锦 代理记账服务 2020阿里巴巴研发效能峰会 企业建站模板 云效成长地图 高端建站 云栖号弹性计算 阿里云云栖号 云栖号案例 云栖号直播