博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL-导入数据
阅读量:7104 次
发布时间:2019-06-28

本文共 1273 字,大约阅读时间需要 4 分钟。

以下:citeulike是数据库名,user_article是table名

create database citeulike;

create table user_article(user varchar(32), article varchar(12), tag varchar(40));

load data local infile 'path\\data.txt' into table user_article fields terminated by ',';

------------------------------------

删除列表:

delete from user_article;删除表里的内容,表仍在,表头不变

drop table user_article;

drop database citeulike;

------------------------------------

更改表项类型

用到timestamp类型,如果直接用timestamp类型,它默认default current_timestamp on update current_timestamp: 默认值是当前时间,并且该行其它项发生修改时自动更新时间

default current_timestamp:默认值是当前时间,不会自动更新时间

default 0/null:默认值是0/null

default 0/null on update current_timestamp:默认值是0/null,自动更新

on update current_timestamp:没写默认值,通常默认0

想把post_time的类型从current_timestamp on update current_timestamp改成default 0:

alter table user_article change post_time post_time timestamp default 0;

(改成default null显示错误:invalid default value for 'post_time')

在表里添加字段:

alter table article_abstract add title mediumtext;

------------------------------------

导出数据时

select * from user_article into outfile 'path\output.txt' fields terminated by '\t' lines terminated by '\r\n'; 显示:mysql server is running with the --secure-file-priv option so it cannot execute this statement

 

转载于:https://www.cnblogs.com/yuchenkit/p/5350890.html

你可能感兴趣的文章
Visual Studio 2015 for Linux更好地支持Linux下的开发
查看>>
InfoQ趋势报告:DevOps 和云计算
查看>>
promise介绍--基础篇
查看>>
在MySQL和PostgreSQL之外,为什么阿里要研发HybridDB数据库?
查看>>
解读:Java 11中的模块感知服务加载器
查看>>
Java8(3):Java8 中 Map 接口的新方法
查看>>
QCon旧金山演讲总结:阿里无线技术架构演进
查看>>
GitHub Octoverse 2018调查要点
查看>>
高效使用微软Azure服务总线的消息功能
查看>>
译文-G1收集器
查看>>
敏捷项目管理,POLYV来支招
查看>>
TensorFlow技术发展与落地实践
查看>>
Grafana 6.0正式发布!新增查询工作流,全新独立Gauge面板
查看>>
使用SpringBoot开启微服务之旅
查看>>
智能化运维等先进技术助力腾讯云DC入驻法兰克福
查看>>
你以为AlphaGo只是下围棋厉害?不,它还能用来优化金融交易策略参数
查看>>
C#的未来:异步序列
查看>>
AWS EC2 Run Command特性新增多重云脚本
查看>>
编辑器之争
查看>>
flume架构解析
查看>>