MySql 1 Create a database in MySQL using 4 or more tables 2

MySql:
1 Create a database in MySQL using 4 or more tables.
2. Use primary, foreign or composite keys for the tables.
3. Use the command to view your table structure.
4. Use the INSERT command to load information into all of the tables.
5. Use the ALTER command to add a column to a table or modify a column of data in a table.
6. Use the DELETE command to delete a row from one of the tables.
7. Use the UPDATE common to change a value of information in a table that has a added column.
8. Use the reserve word Distinct in a SQL statement.
9. to see 2 fields in two tables.
10. RENAME one of the tables.
11. Use the command to save the information from all of the tables.
12. Use the the command to count all the rows in one of your tables.
13. Use the commands to see all the information in your tablels with no duplicates.
14. Add a row with your first: last name and the other necded information required in one of the rows of your table.
15. Use SQL and the commands to see all the information that was revised in the table/tables using MySQL.
16. Join all tables and select a field of information from each table in a report using SQL/MySQL.
17. Create a new table from one of your existing tables.
18. Use the SHOW COLUMNS command to display the structure of the table.
Please answer all these 18 questions clearly . thanks

Solution

Hi, Please find below all the answers with detailed explination.

1. Create a database in MySQL using 4 or more tables.

Answer : You can create as many as you want databases and you can select it and can work on respective database. You need to follow below command to create database and to use.

mysql> CREATE DATABASE dataBaseName1;
mysql> CREATE DATABASE dataBaseName2;
mysql> CREATE DATABASE dataBaseName3;
mysql> CREATE DATABASE dataBaseName4;
mysql> Use dataBaseName1;

mysql> Use dataBaseName2;

mysql> Use dataBaseName3;

mysql> Use dataBaseName4;

In this way you can create and select database in MySQL


2. Use primary, foreign or composite keys for the tables.

Answer :

CREATE TABLE IF NOT EXISTS `TableName` (
`beggingTime` time NOT NULL,
`day` varchar(8) NOT NULL,
`Id` int(3) NOT NULL,
`maxMembers` int(2) NOT NULL,
`minMembers` int(1) NOT NULL,
PRIMARY KEY (`beggingTime`,`day`,`Id`),
KEY `Id` (`Id`)
)

3. Use the command to view your table structure.

Answer:

mysql> SHOW TableName;


4. Use the INSERT command to load information into all of the tables.

Answer:

INSERT INTO tableName ( field1, ...fieldN )
VALUES
( value1,...valueN );


5. Use the ALTER command to add a column to a table or modify a column of data in a table.

Answer:

ALTER TABLE tableName DROP columnName;

6. Use the DELETE command to delete a row from one of the tables.

Answer:

delete from tableName where ColumnName = value;

7. Use the UPDATE common to change a value of information in a table that has a added column.

Answer:

UPDATE table_name SET field1=new-value1, field2=new-value2 [WHERE Clause]

8. Use the reserve word Distinct in a SQL statement.

Answer:

SELECT DISTINCT columnName1 , columnName2 FROM tableName;

9. to see 2 fields in two tables.

Answer:

SELECT what_to_select FROM tableName WHERE conditionsToSatisfy;

10. RENAME one of the tables.

Answer:

RENAME TABLE oldName TO newName;

11. Use the command to save the information from all of the tables.

Answer:

mysql> SAVE tableName;

12. Use the the command to count all the rows in one of your tables.

Answer:

mysql> SELECT COUNT(*) FROM tableName;

13. Use the commands to see all the information in your tablels with no duplicates.

Answer:

mysql> SELECT DISTINCT(columnName) AS ValueToArrenge FROM tableName;

14. Add a row with your first: last name and the other necded information required in one of the rows of your table.

Answer:

INSERT INTO table_name ( field1, field2,...fieldN )
VALUES
( value1, value2,...valueN );

15. Use SQL and the commands to see all the information that was revised in the table/tables using MySQL.

Answer:

mysql> SELECT * FROM tableName;

16. Join all tables and select a field of information from each table in a report using SQL/MySQL.

Answer:

mysql> SELECT a.columnName, a.columnName2, b.columnName FROM tableName1 a,
tableName b WHERE a.columnName = b.columnName;

17. Create a new table from one of your existing tables.

Answer:

mysql> CREATE TABLE test (a INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (a), KEY(b))
ENGINE=MyISAM SELECT b,c FROM test2;

18. Use the SHOW COLUMNS command to display the structure of the table.

Answer:

mysql> SHOW columnName FROM tableName;

MySql: 1 Create a database in MySQL using 4 or more tables. 2. Use primary, foreign or composite keys for the tables. 3. Use the command to view your table stru
MySql: 1 Create a database in MySQL using 4 or more tables. 2. Use primary, foreign or composite keys for the tables. 3. Use the command to view your table stru
MySql: 1 Create a database in MySQL using 4 or more tables. 2. Use primary, foreign or composite keys for the tables. 3. Use the command to view your table stru

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site