MySQL 命令操作数据表

1.查看表信息

desc hs_user_credit_info;

2.新增表字段

alter table hs_credit_order add search_relation_names varchar(80) comment '尽调主体关联人-查询对象关联关系' ;

3.修改字段是否为null,修改描述:

alter table hs_user_credit_info modify credit_status int not null comment '状态:0风控审批结束 1有效 2作废 3过期';

4.修改字段名:

alter table student change physics physisc char(10) not null;

5.刷新表数据,但是不想更新修改时间

alter table hs_loan_order modify modify_time timestamp not null default CURRENT_TIMESTAMP;
 
-- update ....

alter table hs_loan_order modify modify_time timestamp not null default CURRENT_TIMESTAMP  ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间';

就是修改modify_time的默认值

本来的想法是直接去掉默认值

alter table hs_loan_order alter column modify_time  drop default;

发现这样只能去除创建时更新时间更新,不能去除update时的刷新。

可以通过下面语句查看:

 desc hs_loan_order;

也可以将更新语句写为:

      	update hs_capital_attachment_sync_info a,
	(select max(order_by) order_by from hs_capital_attachment_sync_info) b
	set a.order_by=b.order_by+1,a.modify_time=a.modify_time
	where a.capital_order_id= #{capitalOrderId,jdbcType=VARCHAR} and a.file_type=#{fileType,jdbcType=INTEGER}

其中的不更新原有时间为:a.modify_time=a.modify_time

6.远程连接操作mysql

mysql -h18.16.200.6 -uroot -pshitou$root -P3306 

如果有异常信息:

mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2026 (HY000): SSL connection error: error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol

可以使用下面命令登录

mysql -h18.16.200.6 -uroot -pshitou$root -P3306 --ssl-mode=DISABLED

为了不被别人使用ps命令查看到密码,可以使用下面的方式

直接使用别名

alias mysqllogin="mysql -hhostname -uusername -ppassword"

参考:

mysql- 修改字段

mysql alter 用法,修改表,字段等信息

MySQL:如何设置远程登陆不需要输入密码?

posted @ 2018-08-29 16:44  hongdada  阅读(270)  评论(0)    收藏  举报