sql - How to display the tables within MySQL? Keeps showing empty set -


this first time doing mysql. using mysql 5.6 command line client , trying display tables , shows empty set. here's script statements want execute:

create database acmeonline;  create table item(item_number integer default 0, item_name varchar(35) default 'no data', model_num varchar(15) default 'no data',  ->description varchar(255) default 'no data', price double(8,2) not null default 0.00, category_name varchar(35),   ->constraint item_item_number_pk primary key(item_number),   ->constraint item_category_name_fk foreign key(category_name) references category(category_name));  create table category(category_name varchar(35), shippingperpound double(4,2), discountsallowed char(1),   ->constraint category_category_name_pk primary key(category_name));  create table line_item(quantity tinyint(2), shipping_amount double(6,2), orderid integer, item_number integer,  ->constraint line_item_orderid_fk foreign key(orderid) references order_item(orderid),  ->constraint line_item_item_number_fk foreign key(item_number) references order_item(item_number));  create table order_item(orderid integer, item_number integer, primary key(orderid, item_number));  create table order(orderid integer, total double(10,2), constraint order_orderid_pk primary key(orderid), customerid integer, offercode varchar(15),   ->constraint customer_offer_customerid_fk foreign key(customerid) references customer(customerid),   ->constraint customer_offer_offercode_fk foreign key(offercode) references offer(offercode));   create table customer_offer(customerid integer, offercode varchar(15), primary key(customerid, offercode));   create table offer(offercode varchar(15), minamount double(4,2) not null, discount varchar(35), expirationdate char(8) not null,    ->constraint offer_offercode_pk primary key(offercode));   create table customer(customerid integer, customername varchar(50), address varchar(150), email varchar(80),    ->constraint customer_customerid_pk primary key(customerid));   create table business(purchaseterms varchar(50), customerid integer, constraint business_customerid_pk primary key(customerid),   ->foreign key(customerid) references customer(customerid));   create table home(creditcardnum bigint(16) not null, cardexpiration char(7) not null, constraint home_customerid_pk primary key(customerid),   ->foreign key(customerid) references customer(customerid));   create table contact(contactname varchar(50), contactphone char(12) not null, constraint contact_contactname_pk primary key(contactname),   ->foreign key(customer id) references business(customerid));   show tables;  describe item;  describe category;  describe line_item;  describle order_item;  describe order;  describe customer_offer;  describe offer;  describe customer;  describe business;  describe home;  describe contact; 

within mysql 5.6 command line client:

 mysql> use acmeonline;  database changed  mysql> show tables;  empty set (0.00 sec)  mysql> describe item; //the rest of table names repeated.  error 1146 (42s02): table 'acmeonline.item' doesn't exist 

i have no idea last line means though have table of item created in database named acmeonline. maybe i'm missing important, don't know though. appreciated!

you should've changed database after you've created it. right tables reside in database has been used when connected mysql or last database manually changed before executing create table statements.

 mysql> create database acmeonline; query ok, 1 row affected (0.00 sec)  mysql> use acmeonline; database changed 

then create tables

 mysql> create table test(id int); query ok, 0 rows affected (0.02 sec)  mysql> show tables; +----------------------+ | tables_in_acmeonline | +----------------------+ | test                 | +----------------------+ 1 row in set (0.00 sec) 

the other way ensure tables created in correct database use dot notation <database_name>.<table_name>

 mysql> use mysql; database changed  mysql> create table acmeonline.test1(id int); query ok, 0 rows affected (0.01 sec)  mysql> use acmeonline; database changed  mysql> show tables; +----------------------+ | tables_in_acmeonline | +----------------------+ | test                 | | test1                | +----------------------+ 2 rows in set (0.00 sec) 

Comments