程序媛计划——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 ...
随机推荐
- Codeforces 677C. Coloring Trees dp
C. Coloring Trees time limit per test:2 seconds memory limit per test:256 megabytes input:standard i ...
- lnmp vhost 虚拟目录配置
以前常用Windows 很熟悉,lnmp 配置虚拟目录也很简单. 安装完lnmp环境之后,在nginx的配置文件夹下,我采用的方法是复制default.conf 然后重命名为vhost_a.conf ...
- WCF数据契约代理和已知类型的使用
using Bll; using System; using System.CodeDom; using System.Collections.Generic; using System.Collec ...
- C山寨C++
#include <stdio.h> #include <string.h> #include <malloc.h> typedef struct Aclass_s ...
- nginx集群tomcat,session共享问题
tomcat-redis-session-manager版本: apache-tomcat-8.0.32.nginx-1.13.12.redis_3.2.1 github地址: https://git ...
- 实现WIFI MAC认证与漫游
前言 单位里有10来个网件的AP(WNAP210),需要对接入端(主要是手机)进行MAC认证,原来采用AP本地MAC认证,但是人员经常变动(离职),另外人员的岗位(流水线)也经常调整,这样就需在变动后 ...
- [GO]kafka的生产者和消费者
生产者: package main import ( "github.com/Shopify/sarama" "fmt" "time" ) ...
- 数据库面试sql
问题一:.有三张表,学生表S,课程表C,学生课程表SC 01:写出建表语句 答: create table s(id integer primary key,name varchar(20)); cr ...
- UVa 508 Morse Mismatches (模糊暴力)
题意:莫尔斯电码,输入若干个字母的Morse编号,一个字典和若干编码.对于每个编号,判断它可能的是哪个单词, 如果有多个单词精确匹配,输出第一个单词并加一个“!”:如果无法精确匹配,那么在编码尾部增加 ...
- Swift要点:从Objective-C开发者的角度看Swift
代码环境是Xcode6.3-Beta3. Swift已经极大的改变了开发iOS应用的方式.本文中,我会列出Swift的几个重点,并且和Objective-C一一做出对比. 注意,本文不是Swift的入 ...