mysql修改记录
增加一列:alter table bf_agt_dep_acct_sap_sub add column cust_age varchar(10) not null;
改变属性:alter table bf_agt_dep_acct_sap_sub modify cust_age int;
同时改变列名和属性:alter table student change column sname stuname varchar(20);
设置一列的值:update bf_agt_dep_acct_sap_sub set cust_age=19;
随机赋值:update bf_agt_dep_acct_sap_sub set cust_age = round(rand() * 50) + 1 where floor is null;
删除列:alter table bf_agt_dep_acct_sap_sub drop column cust_age;
改变列的大小写:update table set mediafile =lower(mediafile); //lower(),upper(),lcase(),ucase()
改变某一行的值:
注意:mysql字段名不区分大小写,表名区分
创建表:create table datausb(time varchar(20),temp int,humid int);
修改表名:alter table datausb rename to datausb0;
导入表格:load data local infile '/home/kang/Desktop/temp/datausb0.txt' into table datausb fields terminated by '\t';
load data local infile '/home/kang/Desktop/temp/data1.txt' into table BF_PR_IND_INFO_ECTIP fields terminated by '\t' lines terminated by '\r\n';
转化格式: iconv -f gb2312 -t utf8 ./data.txt >./data1.txt
导出表格:只导出数据,而不是一个insert的建表集(mysqldump)
方法一:select * from datausb0 into outfile '/home/kang/Desktop/temp/datausb0.txt' fields terminated by '\t' lines terminated by '\r\n';
出现错误:Can't create/write to file (Errcode: 13)
在确认不是目录权限的问题后,用下面方法解决
setsebool -P mysqld_disable_trans=1
方法二:mysql -uroot -p123456 -e "select * from datausb0" kang >/home/kang/Desktop/temp/datausb0.txt
由出生日期计算年龄:
year(birthday)-year(now()) 反了。。
select a.cust_name as cust_name,year(a.birday)-year(now()) as cust_age,b.original_dep_open_dt as original_dep_open_dt,b.update_dt as update_dt,a.month_incom as month_incom from bf_pr_ind_info_ectip a,b_s_cust_psummary b where a.dcc_custno = 'A4301111999102221290' and a.cert_no = b.cert_no0
查询各个字段
select COLUMN_NAME from information_schema.columns where table_schema= 'chen' and table_name= 'testpos';
查询字段长度
select count(*) from information_schema.columns where table_schema= 'chen' and table_name= 'testpos';
mysql修改记录的更多相关文章
- mysql实时同步到mssql的解决方案
数据库在应用程序中是必不可少的部分,mysql是开源的,所以很多人它,mssql是微软的,用在windows平台上是非常方便的,所以也有很多人用它.现在问题来了,如何将这两个数据库同步,即数据内容保持 ...
- mysql权限修改记录
select user, password, host from mysql.user; GRANT ALL PRIVILEGES ON *.* TO 'root'@'147.114.169.197' ...
- 在node.js中,使用基于ORM架构的Sequelize,操作mysql数据库之增删改查
Sequelize是一个基于promise的关系型数据库ORM框架,这个库完全采用JavaScript开发并且能够用在Node.JS环境中,易于使用,支持多SQL方言(dialect),.它当前支持M ...
- Mysql性能优化二
接上一篇Mysql性能优化一 建立适当的索引 说起提高数据库性能,索引是最物美价廉的东西了.不用加内存,不用改程序,不用调sql,只要执行个正确的'create index',查询速度就可能提高百倍千 ...
- Xtrabackup原理及使用innobackupex进行MySQL数据库备份恢复
Xtrabackup是由percona提供的mysql数据库备份工具,据官方介绍,这也是世界上惟一一款开源的能够对innodb和xtradb数据库进行热备的工具. Xtrabackup中主要包含两个工 ...
- 【转】MySQL索引背后的数据结构及算法原理
摘要 本文以MySQL数据库为研究对象,讨论与数据库索引相关的一些话题.特别需要说明的是,MySQL支持诸多存储引擎,而各种存储引擎对索引的支持也各不相同,因此MySQL数据库支持多种索引类型,如BT ...
- [转]MySQL索引背后的数据结构及算法原理
摘要 本文以MySQL数据库为研究对象,讨论与数据库索引相关的一些话题.特别需要说明的是,MySQL支持诸多存储引擎,而各种存储引擎对索引的支持也各不相同,因此MySQL数据库支持多种索引类型,如BT ...
- MySQL InnoDB存储引擎
200 ? "200px" : this.width)!important;} --> 介绍 本篇文章是对Innodb存储引擎的概念进行一个整体的概括,innodb存储引擎的 ...
- 将数据从MySQL迁移到Oracle的注意事项
将数据从MySQL迁移到Oracle的注意事项1.自动增长的数据类型处理MYSQL有自动增长的数据类型,插入记录时不用操作此字段,会自动获得数据值.ORACLE没有自动增长的数据类型,需要建立一个自动 ...
随机推荐
- getResource()和getSystemResource()分析
1. getClass().getResource() 第一步,getClass().getResource(path)是有一个路径参数的,这个路径会先被转换成"类所在的包名称+path&q ...
- tomcat启动报错
[toc]启动错误 does not exist or is not a readable directory 问题:tomcat启动报错:does not exist or is not a rea ...
- android 中string.xml中的%1$s
idView.setText(getString(R.string.estate_id, mCollectParamObj.getPlotNo())); estate_id:小区号%1$s %d ...
- Codeforces B. Divisiblity of Differences
B. Divisiblity of Differences time limit per test 1 second memory limit per test 512 megabytes input ...
- scanf后面跟一个getchar
scanf(“%d",&a): if(getchar() != '\n') printf();else printf(); 这种情况下,我有点迷惑,就做了个实验,结论是: 1.当输完 ...
- 使用hexo搭建个人博客
安装前提 node.js git 如果缺少以上条件,则前往相应的官网下载安装即可.. 安装hexo $ npm install hexo-cli -g 待安装完成后,执行相关命令查看hexo的信息. ...
- canvas-海底气泡(面向对象编程)
需求:自动生成若干气泡,从海底往上浮: 1.基本的HTML结构: <!DOCTYPE html> <html> <head lang="en"> ...
- Flask之基于route装饰器的路由系统(源码阅读解析)
一 路由系统 1. 在flask中配置URL和视图函数的路由时,首先需要在main.py中实例化一个app对象: from flask import Flask, render_template ap ...
- 探索从 MVC 到 MVVM + Flux 架构模式的转变
本文首发于 my blog 在业务中一般 MVVM 框架一般都会配合上数据状态库(redux, mobx 等)一起使用,本文会通过一个小 demo 来讲述为什么会引人数据状态库. 从 MVC 到 MV ...
- k短路模板 POJ2449
采用A*算法的k短路模板 #include <iostream> #include <cstdio> #include <cstring> #include < ...