标签:推荐 显示 varchar ike val 数据库表 例子 逻辑运算 base
显示数据库
show databases
进入指定数据库
use 数据库名称
create database 数据库名称 default character set=utf8
drop database 数据库名称
二、数据库表的操作
create tabale studentinfo( name varchar(10) not null, sex char(10) null, age int(5), phone bigint(11) ) studentinfo 为所创建的表名
drop table 表名;
# 一次增加一条数据 insert into studentinfo (name,sex,age) values(‘黎诗‘,‘女‘,‘12‘)
# 一次增加多条数据 insert into studentinfo (name,sex,age) values(‘黎诗‘,‘女‘,‘21‘),(‘诗诗‘,‘女‘,‘22‘) insert into 表名称 (字段名称,多个以,间隔) values (具体的值多个以,间隔)
update studentinfo set name = ‘黎诗‘ where name = ‘小诗诗‘
delete from 表名 where 条件
三、数据库表的简单查询(一个简单小例子)
select * from people
select p_name,p_age from people
select * from people where p_age = ‘20‘
select * from people where p_age < ‘60‘ 查询年龄不等于60岁 的人员 select * from people where p_age <> ‘60‘ (推荐,正式) select * from people where p_age != ‘60‘ (非常规) 常见的逻辑运算符 <, >, =, <=, >=, <>, !=
select * from people where p_age > 50 || p_sal < 8000 # 注意: and 用于连接两个条件 表示并且意思 # or 用于连接两个条件表示 或者意思
select * from people where p_name LIKE ‘张%‘,
select * from prople wherer p_name LIKE ‘%张%‘
# 中间有张字的
select * from people where p_menpai = ‘武当‘ or p_menpai = ‘华山‘ or p_menpai = ‘嵩山‘; select * from people where p_menpai in (‘武当‘,‘华山‘,‘嵩山‘); # 否:not in
select * from people where p_sal >= 5000 and p_sal <= 8900; select * from people where p_sal between 5000 and 8900;
select p_leader from people where p_sal > 3000 ORDER BY p_sal ask
# select p_learder from people where p_age = ‘21‘ # selecr * from people where p_id = ‘p003‘ select * from people where p_id = (selest p_learder from ren where p_age = ‘21‘)
标签:推荐 显示 varchar ike val 数据库表 例子 逻辑运算 base
原文地址:http://www.cnblogs.com/jassin-du/p/8001588.html