基本SQL 语句操作数据增删查改
1、创建数据库: create database <数据库名>。
如:create database student;
2、连接到一个已经存在的数据库: use <数据库名>;
如:use student;
3、删除数据库:drop database <数据库名>。
如: drop database student;
4、创建表:create table <表名>(<列名><列的数据类型>[<列的约束>])
如:create table stuInfo(stuId int primary key,stuName varchar(20) not null)
5、删除表: drop table <表名>
如: drop table stuInfo;
6、改动表:alter table
给表加入新列: alter table <表名> add <列名><列的数据类型>;
加入多列,中间用逗号隔开
如:alter table stuInfo add stuGender varchar(10)
改动某列的数据类型:alter table <表名> modify <列名><新数据类型>
如:alter table stuInfo modify stuGender int
改动列名:alter table <表名> change <老列名><新列名><数据类型>
如:alter table stuInfo change stuName stuAddress varchar(30)
删除列:alter table <表名> drop <列名>
如: alter table stuInfo drop stuGender
7、将创建的表的语句反向导出: show create table <表名>
8、查询表的全部内容:select * from <表名>
查询表的部分内容: select <列名列表> from <表名>
9、查询表结构:show columns from <表名>
10、插入单行数据:insert into <表名>(<列名列表>) values(<值列表>)
11、插入多行数据:作用相当于将数据从一个表拷贝到还有一个表
insert into <表名> (列名列表) select <select语句>
如将stuInfo表中的全部的学生姓名拷贝到students表中的stuName列中:insert into students(stuName) select stuName from stuInfo
12、删除数据:delete from <表名> where<过滤条件>
如删除stuID为4的人的数据:delete from stuInfo where stuId=4
基本SQL 语句操作数据增删查改的更多相关文章
- 常用SQL语句(增删查改、合并统计、模糊搜索)
转自:http://www.cnblogs.com/ljianhui/archive/2012/08/13/2695906.html 常用SQL语句 首行当然是最基本的增删查改啦,其中最重要的是查. ...
- SQL语句的增删查改
一.增:有2种方法 1.使用insert插入单行数据: 语法:insert [into] <表名> [列名] values <列值> 例:insert into Strdent ...
- sql基本的增删查改语句
1.增---用于向表中插入新的行/数据 语法:insert into 表名(值1,值2,值3...) values(值1,值2,值3,...) 或者 语法:insert [into] <表名&g ...
- MySQL学习-入门语句以及增删查改
1. SQL入门语句 SQL,指结构化查询语言,全称是 Structured Query Language,是一种 ANSI(American National Standards Institute ...
- Mybatis 的动态SQL,批量增删查改
个人博客网:https://wushaopei.github.io/ (你想要这里多有) 批量增删改的接口: public interface BookService { //批量增加 int ...
- SQL基本之增删查改操作
1.为表添加主键 alter table <tablename> add primary key(col); 主键添加前: 主键添加后: 2.插入数据 insert into <ta ...
- ADO.NET教程(2)实现增删查改
声明一个类,在类中实现增删查改的方法 public class AdoNet { //声明连接字符串 public string Sqlstr = "data source={0};data ...
- EF各版本增删查改及执行Sql语句
自从我开始使用Visual Studio 也已经经历了好几个版本了,而且这中间EF等框架的改变也算是比较多的.本篇文章记录下各个版本EF执行Sql语句和直接进行增删查改操作的区别,方便自己随时切换版本 ...
- EF增删查改加执行存储过程和sql语句,多种方法汇总
ActionUrl c = new ActionUrl() { ActionName="test", RequestUrl="/123/123", SubTim ...
随机推荐
- LeetCode(125) Valid Palindrome
题目 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ign ...
- mysql数据库修改字段类型
修改字段类型: alter table 表名 modify column 字段名字 decimal(18, 4) ;
- Leetcode 388.文件的最长绝对路径
文件的最长绝对路径 假设我们以下述方式将我们的文件系统抽象成一个字符串: 字符串 "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" 表示: dir ...
- pytorch中的math operation: torch.bmm()
torch.bmm(batch1, batch2, out=None) → Tensor Performs a batch matrix-matrix product of matrices stor ...
- zoj 2104 Let the Balloon Rise
Let the Balloon Rise Time Limit: 2 Seconds Memory Limit: 65536 KB Contest time again! How excit ...
- hdu6071[最短路+解不等式] 2017多校4
求出所有,从2走到x所需的花费在对 t = 2*min(d1,2, d2,3) 模运算下, 所有剩余系的最短路即可(把一个点拆成 t 个点, 每个点代表一种剩余系), 知道了所有剩余系就可以凑出答案 ...
- ecplise 使用快捷键
1. [ALT+/] 此快捷键为用户编辑的好帮手,能为用户提供内容的辅助,不要为记不全方法和属性名称犯愁,当记不全类.方法和属性的名字时,多体验一下[ALT+/]快捷键带来的好处吧. 2. ...
- 从ip addr add和ifconfig的区别看linux网卡ip地址的结构
今天一个老外在邮件列表上问了一个问题,就是ip addr add和ifconfig的区别,我给他进行了解答,可能因为英语不好吧,解答的很简单,因此我还是要在这里详细说明一下.其实它们之间没有什么区别, ...
- polya burnside 专题
polya题目:uva 11077 Find the Permutationsuva 10294 Arif in DhakaLA 3641 Leonardo's Notebookuva 11077 F ...
- git多人协作--分支
分支: 创建分支: git checkout -b 新分支 切换分支: git checkout 目标分支 删除分支: git branch -d 待删除分支 推送到远程分支: git checkou ...