SQL语句入门

1、数据库

创建数据库:CREATE DATABASE student_teacher;

删除数据库:DROP DATABASE student_teacher;

切换到当前数据库:USE student_teacher;

2、表

创建表:CREATE TABLE student;

删除表:DROP TABLE student;

增加一列:Alter table student add column name char;

3、视图

创建视图:create view stu;

删除视图:drop view stu;

4、简单表数据操作语句

选择:select * from student where no=091120109;

插入元组:insert into student(no,num,sex,grade) values(1,091120109,male,98);

删除元组:delete form student where sex=male;

更新字段属性的值:update student set sex=female where sex=male;

模糊查找:select * from student where num like “%911201%”; //%代表任意的零个或多个字符,’_’表示任意单个字符。

排序(DESC为降序,ASC为升序):select *from student order by num [DESC];

原文地址:https://www.cnblogs.com/joeshine/p/4355500.html