0% found this document useful (0 votes)
2 views

MySQL_Summary_and_Definitions

The document provides a summary of MySQL operations, including table creation, data insertion, updates, retrieval, and constraints. It details the creation of tables, the use of SQL commands like INSERT, UPDATE, and SELECT, and highlights common errors encountered during operations. Key MySQL concepts such as PRIMARY KEY and CHECK constraints are also defined with examples.

Uploaded by

amanmishra00758
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

MySQL_Summary_and_Definitions

The document provides a summary of MySQL operations, including table creation, data insertion, updates, retrieval, and constraints. It details the creation of tables, the use of SQL commands like INSERT, UPDATE, and SELECT, and highlights common errors encountered during operations. Key MySQL concepts such as PRIMARY KEY and CHECK constraints are also defined with examples.

Uploaded by

amanmishra00758
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MySQL Operations Summary and Definitions

Summary of MySQL Operations

1. **Table Creation and Description**


- Created a table `emp1` with columns `empID`, `empname`, and `empadd`.
- Used `DESC emp1;` to view table structure.

2. **Data Insertion**
- Inserted multiple records into `emp1` and `don` tables.
- Attempted duplicate insertion in `don`, resulting in a PRIMARY KEY violation.

3. **Data Update**
- Updated `empname` for `empID = 113` in `emp1`.

4. **Data Retrieval**
- Retrieved all records using `SELECT * FROM emp1;`.
- Used `LIKE` for pattern-based searches.

5. **Data Constraints**
- Added a `CHECK` constraint to the `addr` column in `don` (only allowing ‘lko’ and ‘knp’).
- Violated the constraint while inserting ‘gkp’, resulting in an error.

6. **Errors Encountered**
- Syntax errors (`craete` instead of `CREATE`).
- Using incorrect column names in queries.
- Violating constraints like PRIMARY KEY and CHECK.

Definitions of Key MySQL Concepts

1. **CREATE TABLE**: Used to create a new table.


```sql
CREATE TABLE emp1 (empID INT, empname VARCHAR(10), empadd VARCHAR(10));
```

2. **DESC (DESCRIBE) Statement**: Shows table structure.


```sql
DESC emp1;
```

3. **INSERT INTO**: Adds new records.


```sql
INSERT INTO emp1 VALUES (102, 'aman', 'lko1');
```

4. **Primary Key Constraint**: Ensures uniqueness.


```sql
CREATE TABLE don (id INT PRIMARY KEY, name VARCHAR(45));
```

5. **CHECK Constraint**: Limits allowed values.


```sql
ALTER TABLE don ADD addr VARCHAR(50) CHECK (addr IN ('lko', 'knp'));
```

6. **UPDATE Statement**: Modifies existing records.


```sql
UPDATE emp1 SET empname = 'alok kumar' WHERE empID = 113;
```

7. **DELETE Statement**: Removes records.


```sql
DELETE FROM emp1 WHERE empID = 101;
```

8. **SELECT Statement**: Retrieves data.


```sql
SELECT * FROM emp1;
```

9. **LIKE Operator**: Searches with patterns.


```sql
SELECT * FROM emp1 WHERE empname LIKE 'a%';
```

10. **Error Handling**: Common errors include syntax mistakes, incorrect column names,
and constraint violations.

You might also like