-- 查看有哪些用户 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. Android中对文件的读写进行操作

    1. 在文件的地方生成一个read.txt文件,并且写入一个read数据.IO流用完之后一定要记得关闭. 对于try和catch是对于错误的抓取. 2. 首先先new file来找到那个文件,然后在通 ...

  2. 设置ip地址、掩码、网关、DNS

    @echo offcolor f8mode con cols=40 lines=8echo.echo.echo      设置IP为:echo.set /p ip=              192. ...

  3. Laravel学习之旅(三)

    视图 一.怎么新建视图: 1.视图默认存放路径:resources/views: 2.laravel模板支持原生的PHP,直接可以在resources/views新建一个PHP文件,例如: index ...

  4. 箭头函数中的 this

    JS 每一个 function 都有自己独立的运行上下文,但箭头函数不属于普通的 function,所以没有独立的上下文. 所以在箭头函数里写的 this 其实是包含该箭头函数最近的一个 functi ...

  5. 百度,谷歌,360,搜狗,神马等蜘蛛IP段

    https://www.imydl.com/wzjs/5971.html 记得3月份的时候明月分享过一篇[站长必备:百度.谷歌.搜狗.360等蜘蛛常见IP地址]的文章,好像一直都受到了众多站长们的关注 ...

  6. Apache关闭VirtualHost的Log日志记录

    有时我们的apache产生的日志是超大的并且 没什么用处,这时我们就可以关闭了,关闭apache日志很简单,直接ErrorLog off或 # CustomLog即可. Web server(ex: ...

  7. Git Bash主题配置

    考虑到window的 Vim操作,发现Git Bash自带命令行很好用. Vim写作Markdown真的好用 还不是为了装逼 只是配色很不爽,就找了这个. 不要怕非常简单麻烦,需要2步骤 1- 打开g ...

  8. Dynamics CRM 2011 报表无法显示的问题总结

    一.一般打开报表会出现:该报表无法显示.(reProcessingAborted)和由于运行Microsoft SQL Server Reporting Services 的服务器上没有安装 Micr ...

  9. AI(四): 微信与luis结合(下)

    LUIS(Language Understanding Intelligent Services)是微软新近推出了的的语义理解服务,可以方便用户进行API调用,创建自己场景的语义理解服务,网址为 ht ...

  10. js 取整

    1.丢弃小数部分,保留整数部分 js:parseInt(7/2)  2.向上取整,有小数就整数部分加1  js: Math.ceil(7/2)  3,四舍五入.  js: Math.round(7/2 ...