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
  • 相关阅读:
    推荐大家使用的CSS书写规范、顺序
    只能输入数字的文本框
    js和jQuery 获取屏幕高度、宽度
    jquery插件开发规范
    ie下使用firebug
    equals和==的使用
    引用数据类型的赋值
    数组工具Arrays的基本使用
    冒泡排序
    使用数组对杨辉三角练习
  • 原文地址:https://www.cnblogs.com/hsinfo/p/13643125.html
Copyright © 2011-2022 走看看