mysql基础语句

一.如何进入mysql 在window下面的cmd下
 mysql --help //将显示所有的帮助信息
 mysql --version //将显示版本信息
 mysql --host=/-h 主机名  //联结到某个主机  localhost默认本地
 mysql --user=/-u 用户名
 mysql --password/-p 密码 按下回车再输入比较好
 mysql --compress 压缩传输
 
二.mysql的一些命令
    ?         (\?) Synonym for `help'.
    clear     (\c) Clear the current input statement.
    connect   (\r) Reconnect to the server. Optional arguments are db and host.
    delimiter (\d) Set statement delimiter.  //语句结束符
    ego       (\G) Send command to mysql server, display result vertically.
    exit      (\q) Exit mysql. Same as quit.
    go        (\g) Send command to mysql server.
    help      (\h) Display this help.
    notee     (\t) Don't write into outfile.
    print     (\p) Print current command.
    prompt    (\R) Change your mysql prompt. //提示符
    quit      (\q) Quit mysql.
    rehash    (\#) Rebuild completion hash.
    source    (\.) Execute an SQL script file. Takes a file name as an argument.
    status    (\s) Get status information from the server.
    tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
    use       (\u) Use another database. Takes database name as argument.
    charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
    warnings  (\W) Show warnings after every statement.
    nowarning (\w)  Do not show warnings after every statement.
三.进入数据后进行的操作    
  一.库的操作
   1.库的创建
    create database [if not exists] database_name;
   2.库的修改
    alter database database_name character set latin(字符集名字) collate utf8_polish_ci(校对规则ci代表大小写不敏感);
   3.库的删除
    drop database [if exists] database_name;
   4.库的使用
    use database_name //就ok了
   5.显示库中的表
    show tables;
   6.select version(),database();显示版本信息,数据库名字
  二.表的操作 
   1.表的创建
    create table class130 (
     id int not null auto_increment,
     name varchar not null,
     address varchar(20),
     primary key(id)
     ) engine = myism....
     create table ...as select
     create table ...like
    2.表的修改
    alter table class130 add column age int default 25;
    alter table class130 drop column age;
    
    alter table class130 modify id not null auto_increment;
    alter table class130 change id new_id int not null auto_increment;
    alter table class130 add primary key(id);
    alter table class130 drop primary key;
   3.表的改名
    rename table class130 to newname;
   4.表的删除
    drop table [if exists] class130;
   5.表的描述
    desc table_name;
    show create table table_name;

  三.操作表数据
   1.插入表数据
    insert into table_name[(column_name),...] values(column_name_value,...);
    insert into table_name set column_name=column_name_value,...;
   2.更新表数据
    update table_name set column_name=column_name_value [where ...] [order by ...][limit ...]
   3.删除表数据
    delete from table_name[where ...] [order by ...] [limit ...]
    truncate [table] table_name;  //删除表中所有的数据
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值