创建mysql表的的下拉框
时间: 2024-04-17 10:23:03 浏览: 117
创建两个数据库并查询六个表的MySQL代码如下:
创建数据库1:
CREATE DATABASE my_db1;
使用数据库1:
USE my_db1;
创建表1:
CREATE TABLE table1 (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(20) NOT NULL,
age INT UNSIGNED DEFAULT 0
);
创建表2:
CREATE TABLE table2 (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
address VARCHAR(60) NOT NULL,
phone CHAR(11) NOT NULL
);
创建数据库2:
CREATE DATABASE my_db2;
使用数据库2:
USE my_db2;
创建表3:
CREATE TABLE table3 (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(20) NOT NULL,
password VARCHAR(20) NOT NULL
);
创建表4:
CREATE TABLE table4 (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
email VARCHAR(50) NOT NULL,
gender ENUM('male','female','other') NOT NULL
);
查询表1:
SELECT * FROM my_db1.table1;
查询表2:
SELECT * FROM my_db1.table2;
查询表3:
SELECT * FROM my_db2.table3;
查询表4:
SELECT * FROM my_db2.table4;
查询表5:
SELECT id,name FROM my_db1.table1 WHERE age>20;
查询表6:
SELECT id,address FROM my_db1.table2 WHERE phone LIKE '139%';
阅读全文