zoukankan      html  css  js  c++  java
  • MySQL

    建表
    create table player(
        id int identity,
        card_id char(18),
        name varchar(10),
        sex enum('',''),
        age tinyint,
        tel char(11),
        balance decimal(7,3)
        );
    查看数据库下的所有表
    show tables from football;
    查看表结构
    show columns from football;
    查看表结构方式2
    desc player;
    查看创建表的完整语句
    show create table player;
    添加列
    alter table player add club varchar(30);
    在指定列后添加列
    alter table player add club varchar(30) after name;
    添加新列到最前面    
    alter table player add player_id char(10) first;
    修改列名    
    alter table player change name new_name varchar(30);
    修改列的数据类型
    alter table player modify name varchar(25);
    修改列的排列位置    
    alter table player modify name varchar(10) after id;
    删除列指定列
    alter table player drop club;
    修改表名    
    alter table oldname rename to newname;
    删除数据库表    
    drop table test1,test2;
    删除数据库表前检测表是否存在,不会报错    
    drop table if not exists test1,test2;
    清空表中数据,重置Identity(标识列,自增字段)
    相当于自增列会被初始化,重新从1开始记录。
    truncate table table_name
  • 相关阅读:
    51Nod 1267 4个数和为0 二分
    51Nod 1090 3个数和为0 set 二分优化
    51Nod 1001 数组中和等于K的数对 Set
    Codeforces 890C
    Codeforces 890B
    Codeforces 890A
    51nod 1058 N的阶乘的长度 位数公式
    C#调用本机摄像头
    读取、写入excel数据
    数据库笔记--基本应用
  • 原文地址:https://www.cnblogs.com/hsinfo/p/13643125.html
Copyright © 2011-2022 走看看