当前位置:Gxlcms > 数据库问题 > 数据库的一些知识点复习

数据库的一些知识点复习

时间:2021-07-01 10:21:17 帮助过:1人阅读

在cmd中输入mysql系统可以识别;

数据库由许多表组成,可以使用键作为表格之间的引用。

2.     一些命令及其使用

a)         创建数据库:create database suyd;

b)        查看系统中存在的数据库:show databases;

c)         切换数据库,默认当前操作在这个库中:use suyd;

d)        查看数据库suyd中存在的表:show tables;

e)         创建表:create table users(id int not null auto_increment primary key, username char(30) not null default ‘‘, password varchar(32) not null default ‘‘, age int not null default 0, sex char(4) not null default ‘‘, email varchar(80) not null default ‘‘);(引号存在点问题)‘‘

f)         查看创建的表:show tables;

g)        查看表users的具体结构:desc users;

h)        查看创建表users的语句:show create table users;

i)          对表的操作

    插入:insert into users(id, username, password, age, sex, email) values(‘1’, ‘suyd’, ‘123456’, ‘22’, ‘girl’, ‘847909475@qq.com’);

           查询表users的情况:select * from users; 

    修改:update users set username = ‘su’ where id = 2;

    同时修改多个值:update users set age = 17, sex = ‘girl’;

    同时修改某个人的多个值:update users set age = 20, sex = ‘girl’ where id = 1;

     删除:delete from users where id = 1;

     查询

     查询表的所有情况:select * from users;

     查询表中某项的情况:select id, username from users;

    按照某种要求查询表中某项的情况:

       select id, username, age+10 as age10 from users;

           select id, username, age from users where age > 10;

j)           删除整个表或库:

     drop table users;

     drop database suyd;

数据库的一些知识点复习

标签:

人气教程排行