MySQL命令使用笔记

查询数据库中所有表名

show tables;
# 也可以
select table_name from information_schema.tables where table_schema='xpydw' and table_type='base table';

查询指定数据库中指定表的所有字段名column_name

select column_name from information_schema.columns where table_schema='xpydw' and table_name='users'

创建表结构.这样的建表方式,不仅仅是表的结构,连带着索引也会同时创建.

create table ts01 like ti_o_sms;       

修改表名的语法:

mysql> help alter table
Name: 'ALTER TABLE'
Description:
Syntax:
ALTER TABLE tbl_name
    [alter_specification [, alter_specification] ...]
    [partition_options]

alter_specification:
    table_options
.......| RENAME [TO|AS] new_tbl_name

.......

# 实例
alter table tab1 rename to tab_new;   
posted @ 2020-04-07 18:05  最爱番茄炒蛋  阅读(188)  评论(0编辑  收藏  举报