1��������
create table �����(
�ֶ�1 ������� not null auto_increment comment '��һ���ֶ�',
�ֶ�2 ������� not null default '��' auto_increment comment '��2���ֶ�',
primary key(sno)
)engine=innodb default charset utf8 comment "ѧ���";
ע�⣺comment�����ֶα�ע��not null �����ֶβ�����Ϊ��,default �����ֶε�Ĭ��ֵ
auto_increment �Զ�����
primary key(�ֶ�) ����Ϊ����
//���� create table student( sno int auto_increment comment 'ѧ��', sname varchar(20) charset utf8 collate utf8_general_ci not null, ssex char(4) charset utf8 collate utf8_general_ci default '��', primary key(sno) )engine=innodb default charset utf8;
ע�⣺not null ���ø��ֶβ���Ϊ�գ�default���ø��ֶε�Ĭ��ֵ
primary key ���ֶε�ֵ�������ظ�
auto_increment ���� ֻ����������(int��tinyint��bigint��
2����������
���������
insert into �����(�ֶ�1���ֶ�2....) values(ֵ1,ֵ2....)
���磺
insert into student(sno,sname,ssex) values('1','С��','Ů');
��������
insert into �����(�ֶ�1,�ֶ�2....)values
(ֵ1,ֵ2....),
(ֵ11,ֵ22...)
����:
insert into student(sno,sname,ssex) values(ֵ1,ֵ2....),(ֵ11,ֵ22....);
3������IJ�ѯ���(select)
select * from �����; //��ѯ����������ݣ�*��ʾ��ѯ�����ֶ�
����:select * from student;
select �ֶ�1,�ֶ�2..... from ����� //��ѯ����ָ���ֶε��������
where������ѯ
��������ѯ
����:select sname,s_birth1 from student where s_sex='��';//��ѯs_sex='��'��sname,s_birth1�ֶε����
��������ѯ
����������֮��ʹ��and ���� or���ӣ�and��orͬʱ������������ʱ����and��or�����ʹ��С������ȷ��ִ��˳��
����:select sname,s_birth1 from student where s_sex='��' and s_age=26; //��ѯs_sex='��'����s_age=26
��Χ��ѯ
< > <= >= != <>
���磺select * from student where s_age<>26;
between and �պ���䣬����ǰ�������൱�� >= and <=
���磺select * from student where s_age between 20 and 26;
in() ��ʾij�ֶε�ֵ��С������ߵ����
���磺select * from student where s_age in(20,22,26);//��ѯstudent����s_age�ֶε�ֵΪ20,22,26�����
not in()
���磺select * from student where s_age not in(20,22,26);//��ѯstudent����s_age�ֶε�ֵ����20,22,26�����
like ģ���ѯ
select * from student where s_name like '%��%';
not like ģ���ѯ
���磺 select * from student where sname like '%��%' and sname not like '%��' and sname not like '��%';
˵��:������������ִ��
'%' ��ʾƥ���������ַ� '_' ��ʾƥ��һ���ַ�
4��������ݵ���(���������)
update ����� set �ֶ���=��ֵ where ����;
����:update student1 set s_sex='Ů' where sname='С��';//��һ���ֶ�
update student1 set s_sex='Ů',s_age=30 where sname='С��';//һ���Ķ���ֶ�ʱ�ö��Ÿ���
5��ɾ����е����(���������)
delete from ����� where ����;
����:delete from student1 where s_no=5;