Different Star Patterns in SQL

Introduction

Generally, the patterns are very interesting to perform. We can make as many shapes as we can in patterns. Let us dive into different types of patterns. Now, we are here making shapes using only '*' symbol. Let explore the * patterns in which we can build different patterns.

The SQL Server I am using is Oracle 10g. So, the SQL Pattern Code looks similar to the PL / SQL Codes.

1.) Pattern 1

Sample Pattern

Pattern Code

Input 1

Output 2

* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
PL/SQL procedure successfully completed.

Input 2

Output 2

* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *

PL/SQL procedure successfully completed.

2.) Pattern 2

Pattern Design

Pattern Code

Input 1

Output 1

*
* *
* * *
* * * *
* * * * *

PL/SQL procedure successfully completed.

Input 2

Output 2

*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *

PL/SQL procedure successfully completed.

Input 3

Output 3

*
* *
* * *
* * * *
* * * * *
* * * * * *

PL/SQL procedure successfully completed.

3.) Pattern 3

Pattern Design

Pattern Code 1

Input 1

Output 1

* * * * *
* * * *
* * *
* *
*

PL/SQL procedure successfully completed.

Input 2

Output 2

* * * * * *
* * * * *
* * * *
* * *
* *
*

PL/SQL procedure successfully completed.

Input 3

Output 3

* * * * * * * * * *
* * * * * * * * *
* * * * * * * *
* * * * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*
PL/SQL procedure successfully completed.

4.) Pattern 4

Pattern Sample

Pattern Code

Input 1

Output 2

*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
PL/SQL procedure successfully completed.

Input 2

Output 2

*
* * *
* * * * * * *
* * * * *
* * *
*
PL/SQL procedure successfully completed.

4.) Pattern 4

Pattern Sample

Sample Code

Input 1

Output 1

        *
      * * *
    * * * * *
  * * * * * * *
* * * * * * * * *

PL/SQL procedure successfully completed.

Input 2

Output 2

           *
         * * *

PL/SQL procedure successfully completed.

Input 3

Output 3

                   * 
                 * * * 
              * * * * * 
            * * * * * * * 
          * * * * * * * * * 
        * * * * * * * * * * * 
      * * * * * * * * * * * * * 
    * * * * * * * * * * * * * * * 
  * * * * * * * * * * * * * * * * * 
* * * * * * * * * * * * * * * * * * *

PL/SQL procedure successfully completed.

5.) Pattern 5

Pattern Sample

Pattern Code

Input 1

Output 1

	    * * * * * * * * * * 
         * * * * * * * * 
            * * * * * 
              * * * 
                *

Input 2

Output 2

	 * * * * * * * * * * * * * *
	    * * * * * * * * * * * *
	     * * * * * * * * * * 
	       * * * * * * * * 
	         * * * * * 
	          * * * 
	            *

6.) Pattern 6

Sample Design

Pattern Code

Input 1

Output 1

        *
      * *
    * * *
  * * * *
* * * * *
PL/SQL procedure successfully completed.

Input 2

Output 2

                *
              * *
            * * *
          * * * *
        * * * * *
      * * * * * *
    * * * * * * *
  * * * * * * * *
* * * * * * * * *


PL/SQL procedure successfully completed.





Latest Courses