sql一般操作
2014-05-17 21:18
363 查看
drop table if exists stu;
create table stu(
name varchar(30),
age int,
stuid int not null PRIMARY key AUTO_INCREMENT,
idnum int,
sex varchar(30),
check(sex in ('男','女'))
)charset=utf8;
insert into stu (name,age,idnum,sex)VALUES('damon',789,4678945,'男');
insert into stu (name,age,idnum,sex) VALUES('coco',13,345,'女');
insert into stu (name,age,idnum,sex)values('kitty',13,46,'女');
insert into stu (name,age,idnum,sex)values('alice',14,123,'女');
SELECT * from stu;
select * from stu limit 0,2;
select * from stu where name like '%ce';
select * from stu where name REGEXP "a[sfdl][^ads]";
select * from stu where name in ('damon','alice');
select * from stu where name BETWEEN 'coco' and 'kitty';
select * from stu where name not between 'coco' and 'kitty';
select name as stuname,stuid as id from stu;
drop view if EXISTS young_stu;
create view young_stu as
select name,age from stu where age between 10 and 20;
select * from young_stu where age is not null;
create table stu(
name varchar(30),
age int,
stuid int not null PRIMARY key AUTO_INCREMENT,
idnum int,
sex varchar(30),
check(sex in ('男','女'))
)charset=utf8;
insert into stu (name,age,idnum,sex)VALUES('damon',789,4678945,'男');
insert into stu (name,age,idnum,sex) VALUES('coco',13,345,'女');
insert into stu (name,age,idnum,sex)values('kitty',13,46,'女');
insert into stu (name,age,idnum,sex)values('alice',14,123,'女');
SELECT * from stu;
select * from stu limit 0,2;
select * from stu where name like '%ce';
select * from stu where name REGEXP "a[sfdl][^ads]";
select * from stu where name in ('damon','alice');
select * from stu where name BETWEEN 'coco' and 'kitty';
select * from stu where name not between 'coco' and 'kitty';
select name as stuname,stuid as id from stu;
drop view if EXISTS young_stu;
create view young_stu as
select name,age from stu where age between 10 and 20;
select * from young_stu where age is not null;
相关文章推荐
- 数据库sql 语言一般操作示例
- Sqlplus的一般操作
- SQL一般操作
- 一般sql操作
- PL/SQL Developer的一般操作!
- SQL一般操作
- Asp学习者完整攻略之三:操作SQL:SQL基础:
- Asp+Sql 个人总结对数据库的各种操作
- .net 使用带参数的SQL语句操作ACCESS 经验点滴
- sqlplus的常用操作
- 操作MS SQL Server 存储过程的类(外加ASP.NET MessageBox类)
- SQL的基本操作
- 经常用到的交叉表问题,一般用动态SQL能生成动态列!
- Microsoft SQL Server 2000在复制的时候包含两个过程,攻击者可以操作输入提供恶意参数给存储过程,可导致执行任意命令。
- 用 T-SQL 操作 XML
- sql的一些操作
- SQL操作点滴
- 操作数据:SQL
- Sql Server 和 Access 操作数据库结构Sql语句
- 操作数据:SQL