sql复习

创建数据库my_tester

CREATE DATABASE my_tester DEFAULT charset utf8;

查看数据库是否创建成功 

SHOW DATABASES;

 

创建表

CREATE TABLE my_tester (
id INT (10) NOT NULL UNIQUE PRIMARY KEY,
name VARCHAR (20) NOT NULL,
sex VARCHAR (2),
birth YEAR,
address VARCHAR (50),
) ENGINE = INNODB DEFAULT CHARSET = utf8;

 

根据已有的表my_tester创建新表(复制表)

复制my_tester表结构,创建新表my_tester2

CREATE TABLE my_tester2 LIKE my_tester;

 

复制my_tester表结构和数据,创建新表my_tester3

CREATE TABLE my_tester3 AS SELECT * FROM my_test

 

复制my_tester表结构的id,name,sex字段,创建新表my_tester4

CREATE TABLE my_tester4 AS SELECT id, name, sex FROM my_tester WHERE 1 <> 1;

posted @ 2020-07-10 10:17  Operater  阅读(148)  评论(0编辑  收藏  举报