Oracle使用总结
1、新建表删除表
新建表语句:
CREATE TABLE +表名{
}
create table AFA_USER ( USER_ID VARCHAR2(32) not null, TENANT_ID VARCHAR2(32), USER_CODE VARCHAR2(32), PASSWORD VARCHAR2(32), USER_NAME VARCHAR2(20), USER_TYPE VARCHAR2(20), IDENTITY_CODE VARCHAR2(20), INVLIDATE DATE, --//时间类型:2017/7/28 AUTH_MODE VARCHAR2(20), STATUS VARCHAR2(20), UNLOCK_TIME TIMESTAMP, MENU_STYLE VARCHAR2(20), MENU_ROLE VARCHAR2(128), LASTEST_LOGIN TIMESTAMP, --//时间戳类型:08-5月 -17 12.57.09.000000 下午 ERROR_COUNT INTEGER, --//整型 START_DATE DATE, END_DATE DATE, MAC_ADDRESS VARCHAR2(128), IP_ADDRESS VARCHAR2(128), MOBILE_NO VARCHAR2(15), EMAIL VARCHAR2(32), MAJOR_USERCODE VARCHAR2(32), MAJOR_USERNAME VARCHAR2(20), MAIN_ORGID VARCHAR2(32), MAIN_POSITIONID VARCHAR2(32), CREATE_USER VARCHAR2(32), CREATE_TIME TIMESTAMP, LAST_MODIFY_TIME NUMBER, --//时间戳常用类型,实体用Long进行存储,保存new Date().getTime()时间的毫秒数 constraint PK_AFA_USER primary key (USER_ID) --//设置主键 ); comment on table AFA_USER is --//设置备注信息 ‘用户信息表‘; comment on column AFA_USER.USER_ID is ‘用户ID‘; comment on column AFA_USER.TENANT_ID is ‘租户ID‘; comment on column AFA_USER.USER_CODE is ‘用户账号‘; comment on column AFA_USER.PASSWORD is ‘用户密码‘; comment on column AFA_USER.USER_NAME is ‘用户名称‘; comment on column AFA_USER.USER_TYPE is ‘用户类型(admin)‘; comment on column AFA_USER.IDENTITY_CODE is ‘用户身份证号‘; comment on column AFA_USER.INVLIDATE is ‘密码失效日期‘; comment on column AFA_USER.AUTH_MODE is ‘本地密码认证、LDAP 认证等‘; comment on column AFA_USER.STATUS is ‘正常,挂起,注销,锁定‘; comment on column AFA_USER.UNLOCK_TIME is ‘当状态为锁定时,解锁的时间‘; comment on column AFA_USER.MENU_STYLE is ‘菜单风格‘; comment on column AFA_USER.LASTEST_LOGIN is ‘最近登录时间‘; comment on column AFA_USER.ERROR_COUNT is ‘密码错误次数‘; comment on column AFA_USER.START_DATE is ‘用户有效日期‘; comment on column AFA_USER.END_DATE is ‘用户失效日期‘; comment on column AFA_USER.MAC_ADDRESS is ‘允许设置多个 MAC 地址‘; comment on column AFA_USER.IP_ADDRESS is ‘允许设置多个 IP 地址‘; comment on column AFA_USER.MOBILE_NO is ‘手机号码‘; comment on column AFA_USER.EMAIL is ‘Email地址‘; comment on column AFA_USER.MAJOR_USERCODE is ‘直接主管‘; comment on column AFA_USER.MAJOR_USERNAME is ‘主管姓名‘; comment on column AFA_USER.MAIN_ORGID is ‘所属(主)机构‘; comment on column AFA_USER.MAIN_POSITIONID is ‘所属(主)岗位‘; comment on column AFA_USER.CREATE_USER is ‘创建人‘; comment on column AFA_USER.CREATE_TIME is ‘创建时间‘;
删除表:
drop table table cascade constraints
DROP TABLE AFA_User cascade constraints;
2、更新表字段
新增字段:
ALTER TABLE AFA_USER ADD LAST_MODIFY_TIME NUMBER;
修改字段:
ALTER TABLE AFA_USER MODIFY LAST_MODIFY_TIME NUMBER;
删除字段:
ALTER TABLE AFA_USER DROP COLUMN LAST_MODIFY_TIME ;
3、更新时间戳语句
update afa_user set create_time=to_timestamp(to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘),‘yyyy-mm-dd hh24:mi:ss.ff‘);
4、oracle连接配置
jdbc.url=jdbc:oracle:thin:@192.168.10.222:1521:orcl jdbc.username=gams0502 jdbc.password=bs jdbc.maxActive=500
Mybatis使用总结
1、新建表删除表
新建表语句:
CREATE TABLE +表名{
}
create table AFA_USER
(
USER_ID varchar(32) not null comment ‘用户ID‘, 非空备注
TENANT_ID varchar(32) comment ‘租户ID‘,
USER_CODE varchar(32) comment ‘用户账号‘,
PASSWORD varchar(32) comment ‘用户密码‘,
USER_NAME varchar(20) comment ‘用户名称‘,
USER_TYPE varchar(20) comment ‘用户类型(admin)‘,
IDENTITY_CODE varchar(20) comment ‘用户身份证号‘,
INVLIDATE datetime comment ‘密码失效日期‘,
AUTH_MODE varchar(20) comment ‘本地密码认证、LDAP 认证等‘,
STATUS varchar(20) comment ‘正常,挂起,注销,锁定‘,
UNLOCK_TIME timestamp comment ‘当状态为锁定时,解锁的时间‘,
MENU_STYLE varchar(20) comment ‘菜单风格‘,
MENU_ROLE varchar(128) comment ‘菜单风格角色‘,
LASTEST_LOGIN timestamp comment ‘最近登录时间‘,
ERROR_COUNT int comment ‘密码错误次数‘,
START_DATE datetime comment ‘用户有效日期‘,
END_DATE datetime comment ‘用户失效日期‘,
MAC_ADDRESS varchar(128) comment ‘允许设置多个 MAC 地址‘,
IP_ADDRESS varchar(128) comment ‘允许设置多个 IP 地址‘,
MOBILE_NO varchar(15) comment ‘手机号码‘,
EMAIL varchar(32) comment ‘Email地址‘,
MAJOR_USERCODE varchar(32) comment ‘直接主管‘,
MAJOR_USERNAME varchar(20) comment ‘主管姓名‘,
MAIN_ORGID varchar(32) comment ‘所属(主)机构‘,
MAIN_POSITIONID varchar(32) comment ‘所属(主)岗位‘,
CREATE_USER varchar(32) comment ‘创建人‘,
CREATE_TIME timestamp comment ‘创建时间‘, //时间戳类型
primary key (USER_ID) //设置主键信息
);
alter table AFA_USER comment ‘用户信息表‘; //备注表名
删除表:
drop table if existes 表名
drop table if exists AFA_USER;
2、更新表字段
新增字段:
ALTER TABLE AFA_USER ADD LAST_MODIFY_TIME NUMBER;
修改字段:
ALTER TABLE AFA_USER MODIFY LAST_MODIFY_TIME NUMBER;
删除字段:
ALTER TABLE AFA_USER DROP COLUMN LAST_MODIFY_TIME ;
3、更新时间戳语句
update afa_user set create_time=to_timestamp(to_char(sysdate,‘yyyy-mm-dd hh24:mi:ss‘),‘yyyy-mm-dd hh24:mi:ss.ff‘);
4、Mybatis连接配置
jdbc.url=jdbc:mysql://127.0.0.1:3306/appframe?prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true jdbc.username=root jdbc.password=123456 jdbc.maxActive=500