首页 > 数据库 >数据库-单表结构-建表语句

数据库-单表结构-建表语句

时间:2024-08-28 08:55:05浏览次数:5  
标签:语句 1833 20 int mysql 88 单表 1832 建表

1.mysql -uroot -p
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

2.show databases;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| dcs46 |
| mysql |
| test |
+--------------------+

3.use test;
mysql> use test;
Database changed

5.select database();

6.desc test;

7.mysql> create table student(class int(20),chinese int(20),english int(20),math int(20),name varchar(30),age int(
10),sid int(20) not null primary key auto_increment);

mysql> desc student;
+---------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+----------------+
| class | int(20) | YES | | NULL | |
| chinese | int(20) | YES | | NULL | |
| english | int(20) | YES | | NULL | |
| math | int(20) | YES | | NULL | |
| name | varchar(30) | YES | | NULL | |
| age | int(10) | YES | | NULL | |
| sid | int(20) | NO | PRI | NULL | auto_increment |
+---------+-------------+------+-----+---------+----------------+

mysql> insert into student(class,chinese,english,math,name,age,sid)values(1833,86,90,40,"zhangsan",21,1),(1832,55,86,66,"lisi",23,2),(1833,93,57,98,"zhaoliu",33,3),(1832,84,90,88,"wangwu",24,4),(1833,93,57,22,"lijiu",25,5),(1832,84,98,77,"liuli",27,7),(1833,48,58,88,"wangsan",19,9),(1833,87,60,65,"wangan",19,10),(1832,80,76,88,"wangping",17,11),(1833,null,79,88,"wanghui",20,12);

mysql> select * from student;
+-------+---------+---------+------+----------+------+-----+
| class | chinese | english | math | name | age | sid |
+-------+---------+---------+------+----------+------+-----+
| 1833 | 86 | 90 | 40 | zhangsan | 21 | 1 |
| 1832 | 55 | 86 | 66 | lisi | 23 | 2 |
| 1833 | 93 | 57 | 98 | zhaoliu | 33 | 3 |
| 1832 | 84 | 90 | 88 | wangwu | 24 | 4 |
| 1833 | 93 | 57 | 22 | lijiu | 25 | 5 |
| 1832 | 84 | 98 | 77 | liuli | 27 | 7 |
| 1833 | 48 | 58 | 88 | wangsan | 19 | 9 |
| 1833 | 87 | 60 | 65 | wangan | 19 | 10 |
| 1832 | 80 | 76 | 88 | wangping | 17 | 11 |
| 1833 | NULL | 79 | 88 | wanghui | 20 | 12 |
+-------+---------+---------+------+----------+------+-----+
10 rows in set (0.00 sec)

mysql> select * from student where class=1832; 1、查询1832班的成绩信息
+-------+---------+---------+------+----------+------+-----+
| class | chinese | english | math | name | age | sid |
+-------+---------+---------+------+----------+------+-----+
| 1832 | 55 | 86 | 66 | lisi | 23 | 2 |
| 1832 | 84 | 90 | 88 | wangwu | 24 | 4 |
| 1832 | 84 | 98 | 77 | liuli | 27 | 7 |
| 1832 | 80 | 76 | 88 | wangping | 17 | 11 |
+-------+---------+---------+------+----------+------+-----+
4 rows in set (0.00 sec)

mysql> select * from student limit 4,6;
+-------+---------+---------+------+----------+------+-----+
| class | chinese | english | math | name | age | sid |
+-------+---------+---------+------+----------+------+-----+
| 1833 | 93 | 57 | 22 | lijiu | 25 | 5 |
| 1832 | 84 | 98 | 77 | liuli | 27 | 7 |
| 1833 | 48 | 58 | 88 | wangsan | 19 | 9 |
| 1833 | 87 | 60 | 65 | wangan | 19 | 10 |
| 1832 | 80 | 76 | 88 | wangping | 17 | 11 |
| 1833 | NULL | 79 | 88 | wanghui | 20 | 12 |
+-------+---------+---------+------+----------+------+-----+
6 rows in set (0.00 sec)

标签:语句,1833,20,int,mysql,88,单表,1832,建表
From: https://www.cnblogs.com/hutongxue/p/18383893

相关文章

  • ETL学习之SQL Server数据库常用SQL语句
    在数据仓库和ETL(提取、转换、加载)过程中,SQLServer数据库是一个广泛使用的平台。ETL工程师需要熟练掌握SQL语句,以便有效地从源系统中提取数据,进行转换,并将其加载到目标数据库中。本文将介绍一些ETL工程师常用的SQLServer数据库SQL语句。1.数据提取(Extract)查询特定列SELEC......
  • 【nacos】通过curl语句更新配置文件
    有时候nacos不一定有页面,需要使用到指令去拉取或更新配置获取tokencurl-XPOST'http://{ip}:8848/nacos/v1/auth/login'-d'username={username}&password={password}'获取某个配置,将token拼接最后curl-XGET'http://{ip}:8848/nacos/v1/cs/configs?dataId=application.y......
  • CI3捕获SQL语句异常
    之前遇到数据库语句错误,一直无法捕获异常publicfunctionhehe(){try{$data=array('title'=>123134,'content'=>'aaaaa','aaa'=>222......
  • oracle 查询表空间,新建表空间,赋权表空间,扩展表空间
    oracle查看表空间的方法一、Oracle查询表空间占用情况SELECTa.tablespace_name"表空间名",       total"表空间大小",       free"表空间剩余大小",       (total-free)"表占用空间大小",       ROUND((total-free)/total*100,2......
  • 一种使用树结构优化switch语句的方法
    介绍在日常装B写代码中会经常用到ifelseif语句如:if(1){ } elseif(1){ //TODO }elseif(1){ //TODO }elseif(1){ //TODO }elseif(1){ //TODO }elseif(1){ //TODO }elseif(1){ //TODO }elseif(1){ //TODO }elseif(1){ //TODO }elseif(1)......
  • C#入门(14)Switch语句
    前言先前我们已经学了if语句,知道了他有一个相似的兄弟Switch,那我们就以他们的区别来进入本节的学习。Switch和if都是用来控制程序的流程的条件语句,但是它们有一些区别。语法结构:Switch语句由一个或多个case标签和一个可选的默认标签组成,每个case标签后面是要执行的语句序列......
  • HeidiSQL中一些简单mysql语句的含义(二)
    一、排序#根据年龄进行降序排序select*fromstudentorderbyagedesc;#根据年龄进行升序排序select*fromstudentorderbyageasc;#给字段起别名,as可以省略selectnoas编号,nameas姓名,ageas年龄fromstudentorderbyageasc;#查找前五条select*fr......
  • Java基础学习篇:switch条件语句进阶(最详细版)
    ......
  • 谷歌黑客语句常用语法
    谷歌黑客语句常用语法1.site用于显示目标地址的子域名如:site:baidu.com//可以显示baidu下的所有子域名2.intitle表示在网页标题中第一个出现的关键字网页一次只能搜索一个关键字如:intitle:百度3.allintitle在结果的标题中同时包含多个关键词如:allintitle:百度黑客4.i......
  • C++ 使用 using 声明语句放开基类的重载函数
    #include<functional>#include<string>#include<iostream>#include<vector>#include<memory>#include<set>#include<map>usingnamespacestd;namespace{classAnimal{public:stringGe......