MySQLラーニングノート:データベースとデータベースのテーブルの作成
1599 ワード
まずLinuxでのmysql運転時にsudoを入力する必要があります
sudo mysql
show databases;#
use test;# 'test'( newdb :create database newdb;)
show tables;#
# , 5 , Id,LastName,FirstName,Address,City:
mysql> create table test_table0(
-> Id int,
-> LastName varchar(255),
-> FirstName varchar(255),
-> Address varchar(255),
-> City varchar(255)
-> );
Query OK, 0 rows affected (0.24 sec)
#
mysql> desc test_table0;
+-----------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------+-------+
| Id | int(11) | YES | | NULL | |
| LastName | varchar(255) | YES | | NULL | |
| FirstName | varchar(255) | YES | | NULL | |
|Address | varchar(255) | YES | | NULL | |
| City | varchar(255) | YES | | NULL | |
+-----------+--------------+------+-----+---------+-------+
5 rows in set (0.00 sec)
#
mysql> insert into test_table0(LastName,FirstName,Address,City) values('Carter','Vince','Changping','Beijing');
Query OK, 1 row affected (0.12 sec)
#
mysql> select * from test_table0;
+------+----------+-----------+-----------+---------+
| Id | LastName | FirstName | Address | City |
+------+----------+-----------+-----------+---------+
| NULL | Carter | Vince | Changping | Beijing |
+------+----------+-----------+-----------+---------+
3 rows in set (0.00 sec)