Monday, 16 July 2018

Sample MySQL table

Sample MySQL table

Table structure:
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| name    | varchar(20) | YES  |     | NULL    |       |
| owner   | varchar(20) | YES  |     | NULL    |       |
| species | varchar(20) | YES  |     | NULL    |       |
| sex     | char(1)     | YES  |     | NULL    |       |
| birth   | date        | YES  |     | NULL    |       |
| death   | date        | YES  |     | NULL    |       |
+---------+-------------+------+-----+---------+-------+
Create Table SQL:
1
2
3
4
5
6
7
8
CREATE TABLE pet (
    name VARCHAR(20),
    owner VARCHAR(20),
    species VARCHAR(20),
    sex CHAR(1),
    birth DATE,
    death DATE
);
Sample Data:
nameownerspeciessexbirthdeath
FluffyHaroldcatf1993-02-04
ClawsGwencatm1994-03-17
BuffyHarolddogf1989-05-13
FangBennydogm1990-08-27
BowserDianedogm1979-08-311995-07-29
ChirpyGwenbirdf1998-09-11
WhistlerGwenbird1997-12-09
SlimBennysnakem1996-04-29
Insert sample data SQL:
1
2
3
4
5
6
7
8
9
INSERT INTO pet VALUES
('Fluffy','Harold','cat','f','1993-02-04',''),
('Claws','Gwen','cat','m','1994-03-17',''),
('Buffy','Harold','dog','f','1989-05-13',''),
('Fang','Benny','dog','m','1990-08-27',''),
('Bowser','Diane','dog','m','1979-08-31','1995-07-29'),
('Chirpy','Gwen','bird','f','1998-09-11',''),
('Whistler','Gwen','bird','','1997-12-09',''),
('Slim','Benny','snake','m','1996-04-29','')

0 comments:

Post a Comment