网站首页  汉语字词  英语词汇  考试资料  写作素材  旧版资料

请输入您要查询的范文:

 

标题 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
    如将stuinfo表中的所有的学生姓名复制到students表中的stuname列中:insert into students(stuname) select stuname from stuinfo
    12、删除数据:delete from <表名> where<过滤条件>
    如删除stuid为4的人的数据:delete from stuinfo where stuid=4
随便看

 

在线学习网范文大全提供好词好句、学习总结、工作总结、演讲稿等写作素材及范文模板,是学习及工作的有利工具。

 

Copyright © 2002-2024 cuapp.net All Rights Reserved
更新时间:2025/5/25 17:32:30