给班级建一个档案表,包括以下信息:
姓名、年龄、email、手机号、简介、毕业薪水、入学日期
姓名:char(3)
年龄:tinyint unsigned
email:varchar(30)
tel:char(11)
intro:varchar(1000)
salary:decimal(7,2)
riqi:date
>create table class(
>id int primary key auto_increment, #主键不可重复#
>name char(3) not null default '',
>age tinyint unsigned not null default 0,
>email varchar(30) not null default '',
>tel char(11) not null default '',
>salary decimal(7,2) not null default '1800.68',
>riqi date not null default '2012-03-13'
>)charset utf8;
增:往哪张表添加?给哪几列添加?分别添加什么值?
>insert into class
>(name,age,email,tel,riqi) #此行不填默认为所有列#
>values
>('刘备',99,'[email protected]','13801380000','2012-12-26');
>insert into class
>values
>(2,'关羽',89,'[email protected]','12345678910','1234.56','2010-09-07');
>insert into class
>(name,age,tel)
>values
>('张飞',79,'110'),('赵云',69,'112'),('黄忠',109,'113'),('马超',59,'114');
改:改哪张表?需要改哪几列的值?分别改为什么值?在哪些行生效?
>update class
>set
>email='[email protected]',salary=3999.34
>where
>id=6;
删:要删哪张表的数据?要删哪些行?
>delete from class where name='马超';
查:查哪张表?查哪列?查哪行?
>select * from class;
>select *from class where id<=3;
>select name,tel from class where id =2 ;
>select name from class;