Podcast
Questions and Answers
What is the primary query language used by MS SQL Server?
What is the primary query language used by MS SQL Server?
Which company developed MySQL?
Which company developed MySQL?
In which year did Sun Microsystems acquire MySQL AB?
In which year did Sun Microsystems acquire MySQL AB?
What type of database system is MS SQL Server classified as?
What type of database system is MS SQL Server classified as?
Signup and view all the answers
What is one feature of MySQL that emphasizes its performance capability?
What is one feature of MySQL that emphasizes its performance capability?
Signup and view all the answers
Which version of MySQL was released for Windows in January 1998?
Which version of MySQL was released for Windows in January 1998?
Signup and view all the answers
What is one of the primary advantages of MySQL that is highlighted?
What is one of the primary advantages of MySQL that is highlighted?
Signup and view all the answers
Which of the following is NOT a platform supported by MySQL?
Which of the following is NOT a platform supported by MySQL?
Signup and view all the answers
What happens when a NOT NULL constraint is applied to a column?
What happens when a NOT NULL constraint is applied to a column?
Signup and view all the answers
In the SQL command to create a table, which of the following correctly sets a default value for the SALARY column?
In the SQL command to create a table, which of the following correctly sets a default value for the SALARY column?
Signup and view all the answers
What is the purpose of the PRIMARY KEY constraint in the SQL statement?
What is the purpose of the PRIMARY KEY constraint in the SQL statement?
Signup and view all the answers
How would you modify the SALARY column to add a NOT NULL constraint after the table has been created?
How would you modify the SALARY column to add a NOT NULL constraint after the table has been created?
Signup and view all the answers
Which SQL command correctly drops a DEFAULT constraint from the SALARY column?
Which SQL command correctly drops a DEFAULT constraint from the SALARY column?
Signup and view all the answers
Why would you use the DEFAULT constraint in a table?
Why would you use the DEFAULT constraint in a table?
Signup and view all the answers
What command should be used if you want to add a DEFAULT constraint to an already existing column?
What command should be used if you want to add a DEFAULT constraint to an already existing column?
Signup and view all the answers
What data type is used for the NAME column in the CUSTOMERS table?
What data type is used for the NAME column in the CUSTOMERS table?
Signup and view all the answers
What does the SQL USE statement accomplish?
What does the SQL USE statement accomplish?
Signup and view all the answers
What is a correct syntax for creating a new table in SQL?
What is a correct syntax for creating a new table in SQL?
Signup and view all the answers
Which of the following components is NOT part of the CREATE TABLE statement?
Which of the following components is NOT part of the CREATE TABLE statement?
Signup and view all the answers
What does the NOT NULL constraint signify in a CREATE TABLE statement?
What does the NOT NULL constraint signify in a CREATE TABLE statement?
Signup and view all the answers
What will happen if the DROP TABLE statement is executed correctly?
What will happen if the DROP TABLE statement is executed correctly?
Signup and view all the answers
Which statement correctly describes the ALTER TABLE command?
Which statement correctly describes the ALTER TABLE command?
Signup and view all the answers
In the context of the CUSTOMERS table example, which data type is used for the NAME column?
In the context of the CUSTOMERS table example, which data type is used for the NAME column?
Signup and view all the answers
What is the purpose of the PRIMARY KEY in the CREATE TABLE statement?
What is the purpose of the PRIMARY KEY in the CREATE TABLE statement?
Signup and view all the answers
What SQL command is used to add a foreign key constraint to an existing table?
What SQL command is used to add a foreign key constraint to an existing table?
Signup and view all the answers
Which of the following is true about the CHECK constraint in SQL?
Which of the following is true about the CHECK constraint in SQL?
Signup and view all the answers
What will happen if a record violates a CHECK constraint when being inserted into a table?
What will happen if a record violates a CHECK constraint when being inserted into a table?
Signup and view all the answers
Which statement correctly drops a foreign key constraint?
Which statement correctly drops a foreign key constraint?
Signup and view all the answers
In the CUSTOMERS table, which column has a CHECK constraint applied?
In the CUSTOMERS table, which column has a CHECK constraint applied?
Signup and view all the answers
Which of the following best describes the purpose of the PRIMARY KEY in the CUSTOMERS table?
Which of the following best describes the purpose of the PRIMARY KEY in the CUSTOMERS table?
Signup and view all the answers
What data type is used for the SALARY column in the CUSTOMERS table?
What data type is used for the SALARY column in the CUSTOMERS table?
Signup and view all the answers
What data type is used for the DATE column in the ORDERS table?
What data type is used for the DATE column in the ORDERS table?
Signup and view all the answers
What SQL command is used to ensure that the age of customers is at least 18?
What SQL command is used to ensure that the age of customers is at least 18?
Signup and view all the answers
Which syntax is valid for dropping a CHECK constraint in a SQL table?
Which syntax is valid for dropping a CHECK constraint in a SQL table?
Signup and view all the answers
In the INSERT INTO statement, when may you omit the column names?
In the INSERT INTO statement, when may you omit the column names?
Signup and view all the answers
How do you add multiple records to the CUSTOMERS table in one command?
How do you add multiple records to the CUSTOMERS table in one command?
Signup and view all the answers
What must be true about the values being inserted into a table?
What must be true about the values being inserted into a table?
Signup and view all the answers
What will happen if you try to insert a record with an AGE value less than 18 after the CHECK constraint is applied?
What will happen if you try to insert a record with an AGE value less than 18 after the CHECK constraint is applied?
Signup and view all the answers
If you want to ensure that each customer in the CUSTOMERS table has a unique ID, which constraint should be applied?
If you want to ensure that each customer in the CUSTOMERS table has a unique ID, which constraint should be applied?
Signup and view all the answers
What is the purpose of using the NOT NULL
constraint in the context of the AGE field of the CUSTOMERS table?
What is the purpose of using the NOT NULL
constraint in the context of the AGE field of the CUSTOMERS table?
Signup and view all the answers
Study Notes
MySQL
- Developed by MySQL AB, a Swedish company
- Pronounced "my ess-que-ell"
- Supports various platforms including Microsoft Windows, Linux distributions, UNIX, and Mac OS X
- Available in free and paid versions
- Offers a fast, multi-threaded, multi-user, and robust SQL database server
MySQL History
- Development began in 1994 by Michael Widenius and David Axmark
- First internal release: 23rd May 1995
- Windows version released: 8th January 1998 for Windows 95 and NT
- Version 3.23: beta in June 2000, production release in January 2001
- Version 4.0: beta in August 2002, production release in March 2003
- Version 4.1: beta in June 2004, production release in October 2004
- Version 5.0: beta in March 2005, production release in October 2005
- Sun Microsystems acquired MySQL AB on 26th February 2008
- Version 5.1: production release on 27th November 2008
MySQL Features
- High performance
- High availability
- Scalability and flexibility
- Runs various applications
- Robust transactional support
- Strengths in web and data warehousing
- Strong data protection
- Comprehensive application development
- Management ease
- Open source freedom and 24/7 support
- Lowest total cost of ownership
MS SQL Server
- A Relational Database Management System (RDBMS) developed by Microsoft Inc.
- Primary query languages are T-SQL and ANSI SQL
MS SQL Server History
- 1987: Sybase releases SQL Server for UNIX
- 1988: Microsoft, Sybase, and Aston-Tate port SQL Server to OS/2
- 1989: Microsoft, Sybase, and Aston-Tate release SQL Server 1.0 for OS/2
- 1990: SQL Server 1.1 released with support for Windows 3.0 clients
- 2000: Microsoft releases SQL Server 2000
- 2001: Microsoft releases XML for SQL Server Web Release 1
- 2002: Microsoft releases SQLXML 2.0 (renamed from XML for SQL Server)
- 2002: Microsoft releases SQLXML 3.0
SQL USE Statement
- Used to choose an existing database in the SQL schema
- Syntax: USE DatabaseName;
- Example: USE testDB;
SQL CREATE TABLE Statement
- Creates a new table
- Syntax:
CREATE TABLE table_name( column1 datatype, column2 datatype, column3 datatype,.....columnN datatype, PRIMARY KEY( one or more columns ) );
- Key points:
- CREATE TABLE is the keyword
- table_name is the unique identifier for the table
- column1, column2, column3...columnN define the table's columns and their data types
- The PRIMARY KEY constraint is used to define a unique identifier for each record in the table
Create Table Example
- Creates a CUSTOMERS table with the following columns: ID, NAME, AGE, ADDRESS, and SALARY
- The PRIMARY KEY constraint is set on the ID column
- NOT NULL constraints are used to ensure that the columns ID, NAME and AGE do not contain null values
CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);
SQL DROP TABLE Statement
- Removes a table definition and all data associated with the table
- NOTE: This command permanently deletes the table and its data
- Syntax: DROP TABLE table_name;
- Example: DROP TABLE CUSTOMERS;
SQL ALTER TABLE Statement
- Modifies an existing table
- Adds, deletes, or modifies columns
- Adds or removes constraints
- Example of adding a NOT NULL constraint to the SALARY column of the CUSTOMERS table:
ALTER TABLE CUSTOMERS
MODIFY SALARY DECIMAL (18, 2) NOT NULL;
DEFAULT Constraint
- Specifies a default value for the column, used when no value is specified in the INSERT INTO command
- Example:
CREATE TABLE CUSTOMERS( ID INT NOT NULL, NAME VARCHAR (20) NOT NULL, AGE INT NOT NULL, ADDRESS CHAR (25) , SALARY DECIMAL (18, 2) DEFAULT 5000.00, PRIMARY KEY (ID) );
- This creates the CUSTOMERS table with a default value of 5000.00 for the SALARY column
- To add a DEFAULT constraint to an existing table:
ALTER TABLE CUSTOMERS
MODIFY SALARY DECIMAL (18, 2) DEFAULT 5000.00;
- To drop a DEFAULT constraint:
ALTER TABLE CUSTOMERS
ALTER COLUMN SALARY DROP DEFAULT;
FOREIGN KEY Constraint
- Ensures data integrity by establishing a link between two tables
- References the PRIMARY KEY of another table
- Example of creating ORDERS and CUSTOMERS tables and adding a FOREIGN KEY to the ORDERS table:
CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);
CREATE TABLE ORDERS (
ID INT NOT NULL,
DATE DATETIME,
CUSTOMER_ID INT references CUSTOMERS(ID),
AMOUNT double,
PRIMARY KEY (ID)
);
- The CUSTOMER_ID column in the ORDERS table is a FOREIGN KEY that references the ID column in the CUSTOMERS table.
- To add a FOREIGN KEY to an existing table:
ALTER TABLE ORDERS
ADD FOREIGN KEY (Customer_ID) REFERENCES CUSTOMERS (ID);
- To drop a FOREIGN KEY constraint:
ALTER TABLE ORDERS
DROP FOREIGN KEY Customer_ID;
CHECK Constraint
- Enforces data validation by ensuring all values meet a specific condition
- Example:
CREATE TABLE CUSTOMERS(
ID INT NOT NULL,
NAME VARCHAR (20) NOT NULL,
AGE INT NOT NULL CHECK (AGE >= 18),
ADDRESS CHAR (25) ,
SALARY DECIMAL (18, 2),
PRIMARY KEY (ID)
);
- This creates the CUSTOMERS table with a CHECK constraint on the AGE column that ensures all ages are 18 years or older.
- To add a CHECK constraint to an existing table:
ALTER TABLE CUSTOMERS
ADD CONSTRAINT myCheckConstraint CHECK (AGE >= 18);
- To drop a CHECK constraint:
ALTER TABLE CUSTOMERS
DROP CONSTRAINT myCheckConstraint;
SQL INSERT Query
-
Adds new rows of data to a table
-
Syntax:
INSERT INTO TABLE_NAME (column1, column2, column3,...columnN) VALUES (value1, value2, value3,...valueN);
-
You can omit the column names if values are provided for all columns, ensuring the order matches the table’s column order
-
Example of inserting records into the CUSTOMERS table using the first syntax where specific columns are listed:
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (1, 'Ramesh', 32, 'Ahmedabad', 2000.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (2, 'Khilan', 25, 'Delhi', 1500.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (3, 'kaushik', 23, 'Kota', 2000.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (4, 'Chaitali', 25, 'Mumbai', 6500.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (5, 'Hardik', 27, 'Bhopal', 8500.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (6, 'Komal', 22, 'MP', 4500.00 );
- Example of inserting records into the CUSTOMERS table using the second syntax, where all columns are included in the order that they appear in the table:
INSERT INTO CUSTOMERS VALUES ( 7, 'John' , 30, 'New York', 5000.00 );
INSERT INTO CUSTOMERS VALUES ( 8, 'Mary' , 28, 'Los Angeles', 6000.00 );
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz covers the essential features and historical development of MySQL, a leading SQL database server. You'll learn about its origins, key versions, and performance characteristics. Test your knowledge of MySQL's evolution and capabilities.