how to assign custom id in mysql 1

how to assign custom id in mysql

CREATE TABLE document_control (
  id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  name VARCHAR(10)
);

Here is what the above code is Doing:
1. We’re creating a table called document_control.
2. We’re creating a column called id.
3. We’re creating a column called created_at.
4. We’re creating a column called name.

The id column is the primary key. This means that it’s the unique identifier for each row in the table.

The created_at column is a datetime column. This means that it will store a date and time.

The name column is a varchar column. This means that it will store a string of characters.

The NOT NULL constraint means that the column cannot be left blank.

The PRIMARY KEY constraint means that the column is the primary key.

The AUTO_INCREMENT constraint means that the value of the column will automatically increment.

The DEFAULT CURRENT_TIMESTAMP constraint means that the column will automatically be set to the current date and time.

The VARCHAR(10) constraint means that the column will store a string of characters of up to 10 characters.

The DATETIME constraint means that the column will store a date and time.

The CREATE TABLE statement is used to create a table in a database.

The INSERT INTO statement is used to insert new records in a table.

The UPDATE statement is used to modify the existing records in a table.

The DELETE statement is used to delete existing records in a table.

The SELECT statement is used to select data from a database.

The LIMIT keyword is used to specify the number of records to return.

The ORDER BY keyword is used to sort the result-set in ascending or descending order.

The WHERE clause is used to extract only those records that fulfill a specified condition.

The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

The AND and OR operators are used to filter records based on more than one condition.

The BETWEEN operator selects values within a given range.

The IN operator allows you to specify multiple values in a WHERE clause.

The COUNT() function returns the number of records in a select query.

The AVG() function returns the average value of a numeric column.

The SUM() function returns the total sum of a numeric column.

The MIN() function returns the smallest value of a numeric column.

The MAX() function returns the largest value of a numeric column.

The FIRST() function returns the first value of a column in a select query.

The LAST() function returns the last value of a column in a select query.

The UCASE() function converts a field to upper case.

The LCASE() function converts a field to lower case.

The MID() function extracts a substring from a string.

The LEN() function returns the length of a string.

The ROUND() function rounds a numeric field to the number of decimals specified.

The NOW() function returns the current date and time.

The FORMAT() function formats how a field is to be displayed.

The CONCAT() function is used to concatenate two or more strings.

The CONCAT_WS() function is used to concatenate two or more strings with a separator.

The GROUP BY statement groups rows that have the same values into summary rows, like “find the number of customers in each country”.

The HAVING clause was added to SQL because the WHERE keyword could not be used with aggregate functions.

The UNION operator is used to combine the result-set of two or more SELECT statements.

The UNION ALL operator is used to combine the result-set of two or

Similar Posts