如何应对面试过程中的SQL基本语句

2025-05-23 00:40:18

1、第一步,双击打开MySQL Workbench,创建数据库school,使用create table命令,代码如下:create database school;如下图所示:

如何应对面试过程中的SQL基本语句

2、第二步,接着,使用新创建数据库school,并创建t_student_table表如下图所示:

如何应对面试过程中的SQL基本语句

3、第三步,数据库表创建完毕后,查看数据库表结构,代码如下:desc t_student_table;如下图所示:

如何应对面试过程中的SQL基本语句

4、第四步,将t_student_table表的stu_name字段的数据类型改为varchar(10),代码如下:alter table t_student_table modify stu_name varchar(10) not null;修改完毕后,查看数据库表结构如下图所示:

如何应对面试过程中的SQL基本语句
如何应对面试过程中的SQL基本语句

5、第五步,将stu_birth字段的位置改到stu_sex字段的前面,代码如下:alter table t_student_table mo颊俄岿髭dify stu_birth datetime after stu_name;修改完毕后,查看数据库表t_student_table中的stu_birth的位置如下图所示:

如何应对面试过程中的SQL基本语句
如何应对面试过程中的SQL基本语句

6、第六步,将stu_num字段改名为stu_id,代码如下:alter table t_student_table change stu_name stu_id int(10) not null;修改完后,查看stu_name是否改变成stu_id如下图所示:

如何应对面试过程中的SQL基本语句
如何应对面试过程中的SQL基本语句

7、第七步,将t_student_table 表的stu_addr字段删除,代码如下:alter table t_student_table drop stu_addr;修改完毕后,查看stu_addr是否还存在如下图所示:

如何应对面试过程中的SQL基本语句
如何应对面试过程中的SQL基本语句

8、第八步,在t_student_table 表中增加名为stu_qq的字段,数据类型为varchar,代码如下:alter table t_student_table add stu_qq varchar(16);修改完毕后,查看stu_qq是否添加上如下图所示:

如何应对面试过程中的SQL基本语句
如何应对面试过程中的SQL基本语句

9、第九步,将t_student_table 表改名为t_student_tab,代码如下:a盟敢势袂lter table t_stu颊俄岿髭dent_table rename t_student_tab;修改完后,先查看t_student_table 是否存在,然后查看t_student_tab如下图所示:

如何应对面试过程中的SQL基本语句
如何应对面试过程中的SQL基本语句
如何应对面试过程中的SQL基本语句

10、第十步,查看数据库表t_student_tab的存储引擎,代码如下:show create table t_student_tab;如下图所示:

如何应对面试过程中的SQL基本语句
如何应对面试过程中的SQL基本语句

11、第十一步,将t_student_tab表的存储引擎更改为MyISAM类型,代码如下:alter table t_student_tab engine=MyISAM;并查看修改存储引擎后的数据库表存储引擎如下图所示:

如何应对面试过程中的SQL基本语句
如何应对面试过程中的SQL基本语句
如何应对面试过程中的SQL基本语句
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢