-- 查看有哪些用户 host: % 代表任意地址都可以登录 host: localhost 代表仅本地可以连接
select host,user from mysql.user; -- 建库
create database test charset utf8;
-- 刷新
flush privileges
-- 赋权
grant all on *.* to 'admin'@'%'; 将数据库的权限赋给admin用户 
-- 刷新
-- 查看建库过程
show create database test;
-- 选择数据库
use test;
-- 建表
create table test(
name varchar(20),
age int
);
-- 修改表名
alter table test rename new_test; -- 查看建表过程
show create table test;
  show create table test\G -- 格式化输出
-- 查看表结构
describe test; -- 等同show columns from user;
-- 查看表内容
select * from test;
-- 添加内容
insert into test values('tj',18);
insert into test(name) values('tj1');
insert into test(age) values(19);
insert into test(age,name) values(19,'tt');
insert into test values('a',1),('b',2);
-- 查看表内容
select * from test; -- 改内容update(可修改名字及数值)
update test set name='updat' where age=19; -- 不加条件则修改所有的
update test set age=20 where name = 'updat'; -- 不加条件则修改所有的
-- 查看表内容
select * from test; -- 删除内容delete
delete from test where age =1; -- 不加条件则删除整个表的内容
delete from test where age<=>null; -- 删除age为null的数据
-- 查看表内容
select * from test; -- 修改表结构及属性 add增加,change重命名,drop删除,modify修改
-- add 给表添加新的结构
alter table test add gender char(5) default '不知';
-- change 将表头名name 改为username
alter table test change name username varchar(20);
-- drop删除
alter table test drop age; -- 就没有了age属性
alter table test add age char(5) default 18 after username;
-- modify修改属性,不能修改名字
alter table test modify age char(6);
-- 查看建表过程
show create table test;
-- 查看表内容
select * from test; -- 常用的数值类型
create table test1(
a varchar(10) not null,
b char(10) default 'zz',
c text,
d int null,
e tinyint null,
f datetime default '2017-12-21 16:21:10'
);
describe test1;
insert into test1 values('tj','hello','hello',18,17,'1999-9-9 09:09:09');
select * from test1; -- drop table xxx 删除表
-- drop database * 删除所有表

msq_table's methods的更多相关文章

  1. How to implement equals() and hashCode() methods in Java[reproduced]

    Part I:equals() (javadoc) must define an equivalence relation (it must be reflexive, symmetric, and ...

  2. Sort Methods

    heyheyhey ~~ It has been a long time since i come here again...whatever today i will summerize some ...

  3. Top 10 Methods for Java Arrays

    作者:X Wang 出处:http://www.programcreek.com/2013/09/top-10-methods-for-java-arrays/ 转载文章,转载请注明作者和出处 The ...

  4. Don’t Use Accessor Methods in Initializer Methods and dealloc 【初始化和dealloc方法中不要调用属性的存取方法,而要直接调用 _实例变量】

    1.问题:    在dealloc方法中使用[self.xxx release]和[xxx release]的区别? 用Xcode的Analyze分析我的Project,会列出一堆如下的提示:Inco ...

  5. C# Extension Methods

    In C#, extension methods enable you to add methods to existing class without creating a new derived ...

  6. CLR via C# 3rd - 08 - Methods

       Kinds of methods        Constructors      Type constructors      Overload operators      Type con ...

  7. 转 Dynamics CRM Alert and Notification JavaScript Methods

    http://www.powerobjects.com/2015/09/23/dynamics-crm-alert-and-notification-javascript-methods/ Befor ...

  8. AX7: HOW TO USE CLASS EXTENSION METHODS

    AX7: HOW TO USE CLASS EXTENSION METHODS   To create new methods on a standard AX class without custo ...

  9. Keeping Async Methods Alive

    Consider a type that will print out a message when it’s finalized, and that has a Dispose method whi ...

随机推荐

  1. gettimeofday的使用

    前言 好像只能在linux平台使用,在windows平台不能使用.... #include <sys/time.h> long cur_tp, cost_tp, tmp_tp; struc ...

  2. [LeetCode&Python] Problem 669. Trim a Binary Search Tree

    Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that a ...

  3. 洛谷 1020:导弹拦截(DP,LIS)

    题目描述 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度.某天,雷达捕捉到敌国的导弹 ...

  4. Try .NET

    微软新出的好东西——Try .NET,该平台可以让开发者直接在线上编写并运行 .NET 代码. 没啥好说的进去就完事了 平台链接:https://try.dot.net/?fromGist=df448 ...

  5. TP3.2整合uplodify文件上传

    HTML中:<style>#img_upload-queue{width:120px;float:left;} /*uploadify的上传进度条样式,前面的img_upload是根据上传 ...

  6. Android中logcat和日志打印

     一.logcat对日志过滤 1.# logcat --help # logcat --help Usage: logcat [options] [filterspecs] options inclu ...

  7. DOS批处理 - 函数教程

    DOS Batch - Function Tutorial What it is, why it`s important and how to write your own. Description: ...

  8. Python–logging模块知多少

    我们在写程序的时候经常会打一些日志来帮助我们查找问题,这次学习一下logging模块,在python里面如何操作日志. 介绍一下logging模块,logging模块就是python里面用来操作日志的 ...

  9. ActiveMQ默认协议和IO模型优化

    在ActiveMQ的官方网站上,列出了目前ActiveMQ中支持的所有消息协议,它们是:AMQP.MQTT.OpenWire.REST.Stomp.XMPP: 不同的协议需要设置不同的网络监听端口,这 ...

  10. Spring Cloud Netflix项目进入维护模式

    任何项目都有其生命周期,Spring Could Netflix也不例外,官宣已进入维护模式,如果在新项目开始考虑技术选型时要考虑到这点风险,并考虑绕道的可能性. 原创: itmuch  IT牧场 这 ...