zoukankan      html  css  js  c++  java
  • MySQL-导入数据

    以下: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 'pathoutput.txt' fields terminated by ' ' lines terminated by ' '; 显示:mysql server is running with the --secure-file-priv option so it cannot execute this statement

  • 相关阅读:
    js 延迟函数
    reduce
    angular2 select 联动
    小程序图片展示模式
    e.target 和 e.currentTarget
    jquery weui 图片浏览器Photo Browser
    ng2中 如何使用自定义属性data-id 以及赋值和取值操作
    jquery img src赋值
    JQuery 自定义属性取值 赋值
    unsupported media type 415
  • 原文地址:https://www.cnblogs.com/yuchenkit/p/5350890.html
Copyright © 2011-2022 走看看