zoukankan      html  css  js  c++  java
  • mysql学习02

    清空数据库的内容

    drop table tb1; #直接删除表
    
    delete from tb1; #清空表的内容
    truncate table tb1;清空标的内容,速度快 自增数字会从零开始重新计数
    mysql> desc student;
    +----------+-------------+------+-----+---------+----------------+
    | Field    | Type        | Null | Key | Default | Extra          |
    +----------+-------------+------+-----+---------+----------------+
    | sid      | int(11)     | NO   | PRI | NULL    | auto_increment |
    | sname    | varchar(25) | YES  |     | NULL    |                |
    | gender   | varchar(2)  | YES  |     | NULL    |                |
    | class_id | int(11)     | YES  |     | NULL    |                |
    +----------+-------------+------+-----+---------+----------------+
    4 rows in set (0.01 sec)
    
    mysql> desc class;
    +---------+-------------+------+-----+---------+----------------+
    | Field   | Type        | Null | Key | Default | Extra          |
    +---------+-------------+------+-----+---------+----------------+
    | cid     | int(11)     | NO   | PRI | NULL    | auto_increment |
    | caption | varchar(25) | YES  |     | NULL    |                |
    +---------+-------------+------+-----+---------+----------------+
    2 rows in set (0.01 sec)
    
    mysql> alter table student add constraint fk_stu_cls foreign key student(class_id) references class(cid);
    Query OK, 0 rows affected (0.38 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    
    mysql>

    277

    https://www.cnblogs.com/wupeiqi/articles/5713315.html

    https://www.cnblogs.com/wupeiqi/articles/5729934.html

  • 相关阅读:
    翻转数组
    C语言之指针
    C语言之结构体
    C语言之函数
    数据结构之typedef
    数据结构之树
    数据结构之链表
    数据结构之队列
    数据结构之数组
    ssh远程连接控制 linux 口令、密钥连接
  • 原文地址:https://www.cnblogs.com/Mengchangxin/p/9658133.html
Copyright © 2011-2022 走看看