MySQL Articles

Page 7 of 355

Partial Dependency in DBMS

Alex Onsman
Alex Onsman
Updated on 06-Sep-2023 53K+ Views

What is Partial Dependency?Partial Dependency occurs when a non-prime attribute is functionally dependent on part of a candidate key.The 2nd Normal Form (2NF) eliminates the Partial Dependency.Let us see an example −ExampleStudentIDProjectNoStudentNameProjectNameS01199KatieGeo LocationS02120OllieCluster ExplorationIn the above table, we have partial dependency; let us see how −The prime key attributes are StudentID and ProjectNo, andStudentID =  Unique ID of the studentStudentName = Name of the studentProjectNo = Unique ID of the projectProjectName = Name of the projectAs stated, the non-prime attributes i.e. StudentName and ProjectName should be functionally dependent on part of a candidate key, to be Partial Dependent.The StudentName can be determined by StudentID, which makes the relation ...

Read More

How to select last row in MySQL?

Chandu yadav
Chandu yadav
Updated on 02-Sep-2023 61K+ Views

To select the last row, we can use ORDER BY clause with desc (descending) property and Limit 1. Let us first create a table and insert some records with the help of INSERT command. The query is as follows. mysql> create table getLastRecord -> ( -> Id int, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.61 sec) After creating the above table, we will insert records with the help of INSERT command. mysql> insert into getLastRecord values(1, 'John'); Query OK, 1 row affected (0.13 sec) ...

Read More

How to get the datatype of MySQL table columns?

Anvi Jain
Anvi Jain
Updated on 02-Sep-2023 48K+ Views

You can get the MySQL table columns data type with the help of "information_schema.columns".The syntax is as follows −SELECT DATA_TYPE from INFORMATION_SCHEMA.COLUMNS where table_schema = 'yourDatabaseName' and table_name = 'yourTableName'To understand the above syntax, let us first create a table −mysql> create table DataTypeDemo −> (    −> Id int,    −> Address varchar(200),    −> Money decimal(10, 4) −> ); Query OK, 0 rows affected (0.60 sec)Apply the above syntax to get the MySQL columns data type. The query is as follows −mysql> select data_type from information_schema.columns where table_schema = 'business' and able_name = 'DataTypeDemo';The following is the output ...

Read More

Starting and Stopping MySQL Server

AmitDiwan
AmitDiwan
Updated on 02-Sep-2023 85K+ Views

Let us understand how MySQL server can be started and stopped on Linux and Windows −Linux – Start and Stop ServerOn Linux, the start and stop can be done from the command line as shown below −/etc/init.d/mysqld start /etc/init.d/mysqld stop/etc/init.d/mysqld restartLinux – Service CommandsSome Linux types offer service command as well −service mysqld startservice mysqld stop service mysqld restart(or)service mysql startservice mysql stopservice mysql restart Windows – Start and Stop ServerLet us understand how it can be done on Windows −Open 'Run' Window by using Win key + RType 'services.msc'Now search for MySQL service based on the version that ...

Read More

How to create a table with date column?

George John
George John
Updated on 02-Sep-2023 105K+ Views

To create a table with only date column, you can use DATE type. Let us first create a table −mysql> create table DemoTable    (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentName varchar(20),    StudentAdmissionDate DATE    ); Query OK, 0 rows affected (0.47 sec)Insert records in the table using INSERT command −mysql> insert into DemoTable(StudentName, StudentAdmissionDate) values('Chris', now()); Query OK, 1 row affected, 1 warning (0.12 sec) mysql> insert into DemoTable(StudentName, StudentAdmissionDate) values('Robert', curdate()); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(StudentName, StudentAdmissionDate) values('David', '2019-05-21'); Query OK, 1 row affected (0.16 sec)Display all ...

Read More

How do I show the schema of a table in a MySQL database?

Arjun Thakur
Arjun Thakur
Updated on 01-Sep-2023 102K+ Views

To show the schema, we can use the DESC command. This gives the description about the table structure. The following is the syntax. DESCRIBE yourDatabasename.yourTableName; Let us implement the above syntax. mysql> DESCRIBE business.student; The following is the output. +-------+--------------+------+-----+---------+-------+ | Field | Type         | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+-------+ | id    | int(11)      | YES | MUL | NULL    | | | Name  | varchar(100) | YES  | MUL | NULL |  | +-------+--------------+------+-----+---------+-------+ 2 rows in set (0.05 ...

Read More

How to Change Root Password of MySQL or MariaDB in Linux?

Satish Kumar
Satish Kumar
Updated on 24-Aug-2023 859 Views

Introduction As with any password, the root user password for a MySQL or MariaDB database should be changed regularly for security reasons. The root user has complete access and control over all databases and tables within the system, making it a prime target for any potential attacks. Regularly changing the root password can help prevent unauthorized access to your data, as well as provide an added layer of security against potential server breaches. Checking Current Root Password A root user is a powerful administrator account that has full access to the MySQL or MariaDB server. It is important to regularly ...

Read More

DDL(Data definition language)

Amrendra Patel
Amrendra Patel
Updated on 22-Aug-2023 4K+ Views

Data Definition Language(DDL) is used for describing data and its relationship in a database. It is also used to define the database schema. The commands only affect the database structure and not the data. The main DDL commands are create, alter, drop and truncate. Create Statement It is used to create a database or table. While creating the table, we specify table_name, column_name followed by data_types(int, float, varchar, etc) and constraints(primary key, not null, etc) Syntax CREATE TABLE table_name ( column1 datatype, column2 datatype, ..... ) Example In this ...

Read More

Data Control Language(DCL)

Amrendra Patel
Amrendra Patel
Updated on 22-Aug-2023 3K+ Views

DCL(Data Control Language) work is to deal with sql commands that are used to permit a user to access, modify and work on a database. it is used to access stored data. It gives access, revoke access and change the permission to the owner of the database as per the requirement. It helps in how sql can use a user authority to modify or retrieve data and protect against unauthorised access. It complements data manipulation language(DML) and data definition language(DDL). It is the simplest among the three command It is basically used for enforcing data security. DCL Commands ...

Read More

Data Replication

Amrendra Patel
Amrendra Patel
Updated on 22-Aug-2023 2K+ Views

Data replication means copying the data at multiple locations to improve the availability of data. It is used to remove the inconsistency between the same data which results in a distributed database so that users can do their own task without interrupting the work of other users. There are various types of Data Replication in DBMS as follow − Types of Data Replication Transactional Replication It makes a full copy of the database along with the changed data. Transactional consistency is guaranteed because the order of data is the same when copied from publisher to subscriber database. It is ...

Read More
Showing 61–70 of 3,543 articles
« Prev 1 5 6 7 8 9 355 Next »
Advertisements