程序媛计划——mysql修改表结构
#查看表的结构
mysql> desc score;
+------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+----------------+
| id | int(4) | NO | PRI | NULL | auto_increment |
| name | char(20) | NO | | NULL | |
| score | double(16,2) | YES | | NULL | |
| evaluation | char(20) | YES | | normal | |
+------------+--------------+------+-----+---------+----------------+
4 rows in set (0.00 sec)
#alter对字段操作
#添加字段
mysql> alter table exam_score add other int(4) default 10;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
#修改字段变为另一个字段
mysql> alter table exam_score change other evaluation char(20) default 'normal';
Query OK, 4 rows affected (0.02 sec)
Records: 4 Duplicates: 0 Warnings: 0
#删除字段(即删除字段中的所有数据)
mysql> alter table exam_score drop column other;
Query OK, 0 rows affected (0.05 sec)
Records: 0 Duplicates: 0 Warnings: 0
#修改表名
mysql> rename table exam_score to score;
Query OK, 0 rows affected (0.01 sec)
程序媛计划——mysql修改表结构的更多相关文章
- 程序媛计划——mysql连接表
#inner join等值连接/内连接 mysql> select * from info; +------+-------------+----------+ | name | phone | ...
- mysql修改表结构语句
mysql alter 用法,修改表,字段等信息 一: 修改表信息 1.修改表名 alter table test_a rename to sys_app; 2.修改表注释 alter table ...
- MYSQL 修改表结构基本操作一览
查看表的字段信息:desc 表名; 查看表的所有信息:show create table 表名; 添加主键约束:alter table 表名 add constraint 主键 (形如:PK_表名) ...
- Mysql修改表结构详解
添加字段: alter table `user_movement_log`Add column GatewayId int not null default 0 AFTER `Regionid` (在 ...
- mysql 修改表结构以支持事务操作
修改表的类型为 INNODB 的 SQL: alter table category_ ENGINE = innodb; 查看表的类型的 SQL show table status from ...
- 程序媛计划——mysql 插入、查找、修改、删除数据
#插入.查找数据 [mysql>create table if not exists exam_score( ..>id int(4) not null primary key auto_ ...
- 程序媛计划——mysql基本操作
本文适用于mac 在官网上下载community 版mysql,选择dmy这种.在终端中安装好mysql. #进入mysql /usr/local/mysql/bin/mysql -uroot -p ...
- 程序媛计划——mysql索引
定义: 索引是一种单独的.物理的对数据库表中一列或多列的值进行排序的一种存储结构 #为字段创建索引 #在表中的字段中创建索引mysql> create index ind_score on ...
- mysql 修改表结构、表字段注释语句
虽然现在有各种各样的工具可以直接对表结构进行修改,但是我还是喜欢使用语句进行修改.以下语句是对表增加字段.给字段加注释的语句 alter table orders add column isupdyq ...
随机推荐
- centos7下创建mysql5.6多实例
一.mysql安装目录说明mysql5.6以二进制安装包安装在/data/mysql56下数据目录为/data/mysql56/data下配置文件为/etc/my.cnf下 二.多实例目录说明/mys ...
- 读书笔记---改善c#编程的157个建议
1.在拼接string时,如果牵涉到其他类型,先tostring一下会减少装箱操作:频繁操作字符串变量的话,使用stringbuilder效率较高. 2.tryParse相对于parse而言效率高,t ...
- docker实战
docker基础入门 docker网络
- 我的UI启蒙之路
为什么叫UI启蒙之路呢? 我没有学过美术,也不懂设计,但是有的时候也许就是一种命中注定吧,让我知道了UI,并且一发不可收拾的爱上了它. 具体情况是这样的: 我毕业于电力学校,是一名不折不扣的工科生,专 ...
- Java数据结构和算法(一)散列表
Java数据结构和算法(一)散列表 数据结构与算法目录(https://www.cnblogs.com/binarylei/p/10115867.html) 散列表(Hash table) 也叫哈希表 ...
- OSGi 系列(十八)之 基于注解的 Blueprint
OSGi 系列(十八)之 基于注解的 Blueprint 1. 注解实现 blueprint 第一步:bundle 添加 Bundle-Blueprint-Annotation <plugin& ...
- 连接数据库-stone
# -*- coding:utf-8 -*- import pymysql class mysql: def __init__(self, host, port, dbuser, dbpwd, dbn ...
- 学习类App原型制作分享-Wokabulary
Wokabulary是一款多功能词汇学习App,可以学习多国语言词汇.原型的引导页面采用的图片+文字+分页器,需要注意的是分页器选中位置要与页面顺序一致.其次是语言的选择页面,在前面给大家介绍过滚动区 ...
- shiro + struts2 在action 中使用 shiro 注解 @requiresPermissions 报错: 方法找不到,类初始失败
06:36:34,405 ERROR http-8084-2 dispatcher.Dispatcher:38 - Exception occurred during processing reque ...
- jQuery nyroModal 插件遇到问题
nyroModal ver 1.6.2 弹出层插件 浏览更多 初始化大小问题 //页面加载完成后初始化 设置大小 $(function() { $.nyroModalSettings({ widt ...