Database Articles

Page 4 of 546

Add a new value to a column of data type enum in MySQL?

Venu Madhavi
Venu Madhavi
Updated on 22-Jan-2025 26K+ Views

In MySQL, the ENUM is a data type that is used to create a column with a fixed set of values. It is helpful for the fields that have limited alternatives, such as categories, statuses, and color codes. However, as your application evolves, you might need to add more values to the list such as new colors. MySQL allows us to modify ENUM values without dropping and recreating the column. Adding New Value to an ENUM column For adding new values in an ENUM column in MySQL, you shall use the ALTER TABLE command with the MODIFY Keyword. For ...

Read More

Program for Fibonacci numbers in PL/SQL

Sunidhi Bansal
Sunidhi Bansal
Updated on 24-Dec-2024 12K+ Views

Given ‘n’ numbers the task is to generate the Fibonacci numbers in PL/SQL starting from 0 to n, where the Fibonacci series of integers is in the form 0, 1, 1, 2, 3, 5, 8, 13, 21, 34 Where integers 0 (1st place) and 1 (2nd place) will have a fixed place after that, the previous two digits will be added to get the integer of the next place as shown below. 0+1=1 (3rd place) 1+1=2 (4th place) 2+1=3 (5th place) and So on. Formula Sequence F(n) ...

Read More

Show MySQL host via SQL Command?

George John
George John
Updated on 24-Dec-2024 31K+ Views

To display MySQL host via SQL command, use the system variable hostname. Query 1 The following is the query to display the host − mysql > select @@hostname; Output Here is the output − +-----------------+ | @@hostname | +-----------------+ | DESKTOP-QN2RB3H | +-----------------+ 1 row in set (0.00 sec) Query 2 Or you can use "show variables" command to show MySQL host via SQL command. show variables where Variable_name like '%host%'; Output The following is the output − +-------------------------------+-----------------+ | Variable_name | Value | +-------------------------------+-----------------+ | host_cache_size | 279 | | hostname  | DESKTOP-QN2RB3H | | performance_schema_hosts_size | -1 | | report_host | | +-------------------------------+-----------------+ 4 rows in set (0.07 sec)

Read More

Difference between hierarchical and network database model in SQL

Himanshu shriv
Himanshu shriv
Updated on 24-Dec-2024 12K+ Views

Hierarchical Data Model In the Hierarchical data model, the relationship between the table and data is defined in parent-child structure. In this structure, data is arranged in the form of a tree structure. This model supports one-to-one and one-to-many relationships. Network Model The Network model arranges data in a graph structure. In this model, each parent can have multiple children, and children can also have multiple parents. This model supports many-to-many relationships as well. Comparison Table ...

Read More

Reverse a Number in PL/SQL

Prateek Jangid
Prateek Jangid
Updated on 23-Dec-2024 15K+ Views

PL/SQL is a block-structured language that combines SQL's functionality with procedural commands. In this article, we will discuss a program in PL/SQL to reverse a given number for example −Input : 98765 Output : 56789 Explanation : reverse number of 98765 is 56789. Input : 56784 Output : 48765 Explanation Reverse number of ‘56784’ is ‘48765’.Approach to find The SolutionTake out the last digit from the number by finding the remainder of num/10.Now add the last digit to another variable reversed_num.Now check if num becomes 0 −If YES, then go to STEP1.If NO, then go to STEP4.Finally, print the ...

Read More

Difference between correlated and non-collreated subqueries in SQL

Himanshu shriv
Himanshu shriv
Updated on 23-Dec-2024 14K+ Views

SQL query is used to fetch data from the database. In some of the scenario you may need some perquisite data to call subsequent SQL query to fetch data from a table so instead of writing two seperate query we can write SQL query within the query. Therefore subQuery is a way to combine or join them in single query. Subqurey can have two types −Correlated subquery - In correlated subquery, inner query is dependent on the outer query. Outer query needs to be executed before inner queryNon-Correlated subquery - In non-correlated query inner query does not dependent on the outer ...

Read More

Difference between Static SQL and Dynamic SQL

Mahesh Parahar
Mahesh Parahar
Updated on 23-Dec-2024 28K+ Views

Static SQLStatic SQL refers to those SQL statements which are fixed and can be hard coded into the application. As static sqls are fixed queries, these statements can be analyzed and optimized and do not require any specific handling for security purposes.Dynamic SQLDynamic SQL refers to those SQL statements which are generated dynamically based on user's input and run in the application. Dynamic Sqls helps to develop general and flexible applications. Dynamic SQL may need more permissions and security handling and a malicious user can create dangerous code as well.Following are some of the important differences between Static Routing and ...

Read More

Embedded SQL, Dynamic SQL, and SQLJ

Amrendra Patel
Amrendra Patel
Updated on 23-Dec-2024 16K+ Views

Embedded SQL Embedded SQL is a method that combines SQL with a high−level programming language's features. It enables programmers to put SQL statements right into the source code files used to set up an application. Database operations may be carried out effortlessly by developers by adding SQL statements to the application code. The source code files having embedded SQL statements should be preprocessed before compilation because of the issue of interpretation of SQL statements by the high−level programming languages in embedded SQL. The terms EXEC SQL and END_EXEC must be used before and after each SQL statement in the source ...

Read More

Embedded SQL in DBMS

Amrendra Patel
Amrendra Patel
Updated on 23-Dec-2024 35K+ Views

Embedded SQL is a powerful method that allows the integration of high−level programming languages with database management systems (DBMS). It acts as a bridge between applications and databases which helps in data manipulation and communication. Various database management systems offer embedded SQL, giving developers the freedom to select the one that best serves their requirements. Popular DBMS that support Embedded SQL are Altibase, IBM Db2, Microsoft SQL Server, Mimer SQL, Oracle Database, PostgreSQL, and SAP Sybase. Need of Embedded SQL The goal to make database interactions simpler for application developers and end users determines the demand for embedded SQL. ...

Read More

Java – MySQL connection with ipAddress

AmitDiwan
AmitDiwan
Updated on 08-Nov-2024 1K+ Views

In this article, we will learn how to connect a Java application to a MySQL database hosted on a specific IP address. By specifying the IP address in the connection URL, we can directly connect to the database even if it’s on a different machine. We’ll use the DriverManager.getConnection() method to initiate the connection. Steps to connect a MySQL database via IP Address Following are the steps to connect a MySQL database via IP Address − Import Connection and DriverManager classes from the java.sql package to enable database connectivity. Create a String ...

Read More
Showing 31–40 of 5,456 articles
« Prev 1 2 3 4 5 6 546 Next »
Advertisements