知乎:https://www.zhihu.com/people/monkey.d.luffy Android高级开发交流群2: 752871516
全部博文(315)
分类: Oracle
2012-06-01 12:20:49
create table ElecDoc_Class(
Class_ID number,--主键
Class_Name nvarchar2(50),
ParentClass_ID number,
Class_IsUSED number,
CREATED_BY varchar2(20),
CREATED_TIME date,
LAST_EDIT_BY varchar2(20),
LAST_EDIT_TIME date
);
--Class_IsUSED 删除目录时候不真的删除,只是修改使用属性
--创建序列
CREATE SEQUENCE Class_ID
MINVALUE 1000
START WITH 1000
INCREMENT BY 1
CACHE 2;
--删除序列
drop sequence Class_ID
--查询
select * from ElecDoc_Class t;
select Class_ID, Class_Name, ParentClass_ID, Class_IsUSED from ElecDoc_Class
--更新
select * from Elecdoc_Class t for update;
--删除条目
delete ElecDoc_Class where Class_ID=1002
--清空表
TRUNCATE TABLE ElecDoc_Class;
--删除表
SqlDate = string.Format("INSERT INTO SCH_SIGN_RECORD( Login_id, Personnel_id, Name, Department_id, Position_id, On_duty_time, Client_IP) values ( '{0}', {1}, '{2}', {3}, {4}, to_date('{5}', 'yyyy-MM-dd HH24:mi:ss'), '{6}')",
new string[7]
{ sdd.Tables[0].Rows[0]["Login_id"].ToString(), sdd.Tables[0].Rows[0]["Personnel_id"].ToString(), sdd.Tables[0].Rows[0]["Name"].ToString(), sdd.Tables[0].Rows[0]["Department_id"].ToString(), sdd.Tables[0].Rows[0]["Position_id"].ToString(),
SignInTime.ToString(),
ip,
});
SignInTime是DateTime类型,很多东西都可以以此类推,这才是学习的方法!
时间相关SQL2:
string SqlUpdate = string.Format("UPDATE SCH_SIGN_RECORD set Off_duty_time=to_date('{0}', 'yyyy-MM-dd HH24:mi:ss') where Login_id='{1}' and to_char(On_duty_time, 'yyyy/MM/dd')=to_char(sysdate, 'yyyy/MM/dd') and Off_duty_time is null",
new string[2]
{
SignOutTime.ToString(),
UserId,
});
ASP.Net中时间的一些操作(a little)
计算时间差:
///
/// 时间差计算函数的重载
///
///
private string DateDiff()
{
DateTime DateTime2 = Convert.ToDateTime(Label1.Text.ToString());
DateTime DateTime1 = Convert.ToDateTime(Label2.Text.ToString());
string dateDiff = null;
try
{
TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
TimeSpan ts = ts1.Subtract(ts2).Duration();
dateDiff = ts.Hours.ToString() + "小时" + ts.Minutes.ToString() + "分钟" + ts.Seconds.ToString() + "秒";
}
catch
{
}
return dateDiff;
}
获取客户端IP:
//获取客户端IP
string ip = string.Empty;
if (Context.Request.ServerVariables["HTTP_VIA"] != null) //走协议
{
ip = Context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else //不走协议,得不到客户端IP
{
ip = Context.Request.ServerVariables["REMOTE_ADDR"].ToString();
}
还有一些FTP的一些东西,这里就不做笔记,意思不是很大。还是要保密的!虽然不是什么高深的东西,嘻嘻,开玩笑的啦!