buser 发表于 2018-10-3 12:26:06

MySQL初步使用

show tables;  show databases;
  use 数据库名;
  desc user;
  describle 表名;或desc 表名;
  '#', '--'均可用于注释
  create database school;
  drop database school;
  drop database if exists school;
  create table student #建立学生表
  (
  id int(5) auto_increment not null primary key,
  name char(10) not null,
  address varchar(50) default '清华大学'
  year date
  );
  select left(address,10) from student; 只看address的前10个字符
  select count(*) from student;统计记录数
  select (100+98+99)/3;当计算器来用
  select """hello";结果为"hello, 将2个双引号当做1个双引号
  或select "\"hello";结果为"hello
  select '''hello';结果为'hello
  select '\'hello';结果为'hello
  select 0xa+0; 结果为10
  select 0x5061756c; 结果为Paul
  select x'4d7953514c';结果为MySQL
  select hex('cat');结果为636174
  select TRUE,true, FALSE,false;结果为1,1,0,0
  select * from 'select' where 'select'.id>100;
  create table orders('my orders' varchar(100));
  删除表:drop table student;

页: [1]
查看完整版本: MySQL初步使用