-- 查看有哪些用户 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. [LeetCode&Python] Problem 557. Reverse Words in a String III

    Given a string, you need to reverse the order of characters in each word within a sentence while sti ...

  2. Ubuntu终端及VI 快捷键

    Ubuntu终端 快捷键 功能 Tab 自动补全 Ctrl+a 光标移动到开始位置 Ctrl+e 光标移动到最末尾 Ctrl+k 删除此处至末尾的所有内容 Ctrl+u 删除此处至开始的所有内容 Ct ...

  3. poj-1015(状态转移的方向(01背包)和结果的输出)

    #include <iostream> #include <algorithm> #include <cstring> #include <vector> ...

  4. css里涉及到定位相关的example实例

    一,情景导入:正常文档流:指的是HTML文档在进行内容布局时所遵循的从左到右,从上到下的表现方式.HTML中的大多数元素都处在正常的文档流中,而一个元素要脱离正常流的唯一途径就是浮动或定位.二,定位的 ...

  5. 一键分享到各个SNS插件

    使用百度分享:http://share.baidu.com/code/advance#toid 例: HTML: <div class="bdsharebuttonbox" ...

  6. LeetCode-Microsoft-Clone Graph

    Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's ...

  7. 【spring源码分析】面向切面编程架构设计

    2 注解说明 2.1 @Aspect 作用是把当前类标识为一个切面供容器读取 2.2 @Before标识一个前置增强方法,相当于BeforeAdvice的功能,相似功能的还有 2.3 @AfterRe ...

  8. Tomcat配置JNDI数据源的三种方式-转-http://blog.51cto.com/xficc/1564691

    第一种,单个应用独享数据源 就一步,找到Tomcat的server.xml找到工程的Context节点,添加一个私有数据源 Xml代码   <Context docBase="WebA ...

  9. log4net保存到数据库系列二:独立配置文件中配置log4net

    园子里面有很多关于log4net保存到数据库的帖子,但是要动手操作还是比较不易,从头开始学习log4net数据库日志一.WebConfig中配置log4net 一.WebConfig中配置log4ne ...

  10. 在 php 7.3 中 switch 语句中使用 continue

    在 php 7.3 中 switch 语句中使用 continue 在 php 7.3 的 switch 中使用 continue 会出现警告.1 2 3 while ($foo) { switch ...