[SQL] SQL의 종류 ORACLE/SQL 2012. 3. 29. 15:58

정보처리기사나 각종 서적에 보면 DDL, DML, DCL이라는 것을 볼 수가 있다.

여기에선 그 정의를 알아본다. 총 3가지로 나뉠 수가 있다.

DDL(Data Definition Language) - 데이터베이스 객체인 테이블이나 뷰, 인덱스, 시퀀스 등의 구조를 정의 하며 CREATE, DROP, ALTER를 이용한다.

 

DML(Data Manipulation Language) - 데이터의 삽입, 삭제, 업데이트 등을 처리

 

DCL(Data Control Language) - 데이터베이스 사용자 권한 제어한다. GRANT로 권한을 부여하고, REVOKE로 취소한다.

데이터 베이스 다이어그램을 통해서 관계를 맺어주면서 이상한 것을 발견했다

뭐 권한이 없느니 alter 문을 이용해서 권한을 주라는 것이다.

그럴때는 다음과 같이 하면 된다
EXEC sp_dbcmptlevel 데이터베이스, '90';

ALTER AUTHORIZATION ON DATABASE::데이터베이스 TO 로그인 권한 지닌 계정

흠냐 -_-a 하나 하나 하다보면 신기한 것을 알게 된다.

-_- 그냥... 무지 간단하다..

다른거 필요없다;;

혹여나 모르시는 분들을 위해;;

필자도 오랜만에 해본 것이라서 잊을까봐;;

일단 허브에 해당 랜선을 다 꽂는다 -_- 물론 컴퓨터에도 꽂아야겠죠?

그 다음.. -_- DNS를 제외한 IP와 Subnetmask, Gateway를 입력하면.. 끝이다..

아 참고로 -_- 오라클이나 SQL같은 Datadase도 연결 가능하겠죠?^_^

네!! 가능합니다!!
[C#]TCP/IP + SQL -_-a C# 2008. 12. 26. 13:52

흠냐.. -_- 그냥 간단한 형식으로 만들었다

테스팅만 되게..

근데 -_- 근데!! 왜!!

-_- WrteLine만 해서 보낼 경우는 데이터가 왜 안가지 -_-;;

Flush()는 스트림을 비우는게 아닌감 -_-

난 그렇게 알고 있었는데...

뭐 암튼지간 -_- 여기 저기 기웃거림 뭔가 알겠지 -_-;;

******TCP/IP + DataBase Server Code 1:1

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.IO;
using System.Data.SqlClient;

namespace server
{
    public partial class Form1 : Form
    {
        TcpListener server;
        TcpClient client;
        NetworkStream Stream = null;
        StreamReader reader;
        StreamWriter writer;
        Thread reciive;
        bool connect;
        private delegate void MBox();

        public Form1()
        {
            InitializeComponent();
        }    
      
        private void Check()
        {
            try
            {               
                client = server.AcceptTcpClient();
                connect = true;
                Stream = client.GetStream();
                reader = new StreamReader(Stream);
                writer = new StreamWriter(Stream);
                reciive = new Thread(new ThreadStart(Recieve));
                reciive.Start();
            }
            catch (Exception ex) { }
        }

        private void Recieve()
        {
            try
            {
                while (connect)
                {
                    Thread.Sleep(1);
                    if (Stream.CanRead)
                    {
                        Thread.Sleep(1);
                        if (Stream.CanRead)
                        {
                            string temp = reader.ReadLine();
                            if (temp.Length > 0)
                            {
                                Search();
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { }
        }

        private void Search()
        {
            string tests = @"User Id=sa; Password=cjstkd; Server =192.168.1.209; Initial Catalog = test";
            SqlConnection conn;
            SqlCommand cmd;
            SqlDataReader dr;
            try
            {
                conn = new SqlConnection(tests);
                conn.Open();
                cmd = new SqlCommand("select id from ID_PW", conn);
                cmd.CommandType = CommandType.Text;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    writer.WriteLine(dr.GetString(0));
                    writer.Flush();
                }
                dr.Close();
                conn.Close();
            }
            catch (Exception ex) { }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            Thread checkThread = new Thread(new ThreadStart(Check));
            checkThread.Start();
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            connect = false;
            if (reader != null)
                reader.Close();
            if (writer != null)
                writer.Close();
            if (server != null)
                server.Stop();
            if (client != null)
                client.Close();
            if (reciive != null)
                reciive.Abort();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            IPAddress addr = new IPAddress(0);
            int port = 5425;
            server = new TcpListener(addr, port);
            server.Start();
            Check();
            button2.Text="Start";
        }
    }
}

*****TCP/IP Client

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using System.IO;
using System.Threading;

namespace client
{
    public partial class Form1 : Form
    {
        TcpClient client;
        StreamReader reader;
        StreamWriter writer;
        NetworkStream Stream;
        Thread receive;
        bool connect;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try{
                client = new TcpClient();
                client.Connect("192.168.1.209",5425);
                Stream = client.GetStream();
                connect = true;
                reader = new StreamReader(Stream);
                writer = new StreamWriter(Stream);
                receive = new Thread(new ThreadStart(Recieve));
                receive.Start();
            }
            catch(Exception ex){}
        }
                   
        private void Recieve(){
            try{
                while(connect)
                {
                    Thread.Sleep(1);
                    if (Stream.CanRead)
                    {
                        string temp = reader.ReadLine();
                        if (temp.Length > 0)
                            MessageBox.Show(temp);
                    }
                }
            }
            catch(Exception e){}
        }

        private void button2_Click(object sender, EventArgs e)
        {
            writer.WriteLine("search");
            writer.Flush();
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            connect = false;
            if (reader != null)
                reader.Close();
            if (writer != null)
                writer.Close();
            if (client != null)
                client.Close();
            if (receive != null)
                receive.Abort();
        }                   
    }
}

*********************************************************************************
1:다 Server
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.IO;
using System.Data.SqlClient;

namespace server
{
    public partial class Form1 : Form
    {
        TcpListener server;
        TcpClient client = null;
        NetworkStream Stream = null;
        StreamReader reader = null;
        StreamWriter writer = null;
        Thread reciive=null;
        Thread checkThread = null;
        bool connect=false;

        public Form1()
        {
            InitializeComponent();
        }    
      
        private void Check()
        { 
            string temp=null;
            try
            {
                while (true)
                {
                    temp = null;
                    client = server.AcceptTcpClient();
                    connect = true;

                    Stream = client.GetStream();
                    reader = new StreamReader(Stream);
                    writer = new StreamWriter(Stream);
                    temp = reader.ReadLine();
                    if (temp.Equals("search"))
                    {
                        Search();                    
                    }
                    else if (temp.Equals("search1"))
                    {
                        Search1();
                    }
                    temp = null;               
                }
            }
            catch (Exception ex) { }
        }

        private void Recieve()
        {
            try
            {
                while (connect)
                {
                    Thread.Sleep(1);
                    if (Stream.CanRead)
                    {
                        Thread.Sleep(1);
                        if (Stream.CanRead)
                        {
                            string temp = reader.ReadLine();
                            if (temp.Length > 0)
                            {
                                if (temp.Equals("search"))
                                {
                                    MessageBox.Show(temp);
                                    Search();
                                    temp = null;
                                }
                                else if (temp.Equals("search1"))
                                {
                                    MessageBox.Show(temp);
                                    Search1();
                                    temp = null;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex) { }
        }

        private void Search()
        {
            string tests = @"User Id=sa; Password=cjstkd; Server =192.168.1.209; Initial Catalog = test";
            SqlConnection conn;
            SqlCommand cmd;
            SqlDataReader dr;
            try
            {
                conn = new SqlConnection(tests);
                conn.Open();
                cmd = new SqlCommand("select id from ID_PW", conn);
                cmd.CommandType = CommandType.Text;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    writer.WriteLine(dr.GetString(0));
                    writer.Flush();
                }
                dr.Close();
                conn.Close();
            }
            catch (Exception ex) { }
        }
        private void Search1()
        {
            string tests = @"User Id=sa; Password=cjstkd; Server =192.168.1.209; Initial Catalog = test";
            SqlConnection conn;
            SqlCommand cmd;
            SqlDataReader dr;
            try
            {
                conn = new SqlConnection(tests);
                conn.Open();
                cmd = new SqlCommand("select pw from ID_PW", conn);
                cmd.CommandType = CommandType.Text;
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    writer.WriteLine(dr.GetString(0));
                    writer.Flush();
                }
                dr.Close();
                conn.Close();
            }
            catch (Exception ex) { }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
           
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            connect = false;
            if (reader != null)
                reader.Close();
            if (writer != null)
                writer.Close();
            if (server != null)
                server.Stop();
            if (client != null)
                client.Close();             
            if (reciive != null)
                reciive.Abort();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            IPAddress addr = new IPAddress(0);
            int port = 5425;
            server = new TcpListener(addr, port);
           
            server.Start(); 
                     
                checkThread = new Thread(new ThreadStart(Check));
               
                checkThread.IsBackground = true;
                checkThread.Start();
            button2.Text="Start";
        }
    }
}
*********************************************************************************
1:다 Client
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using System.IO;
using System.Threading;

namespace client
{
    public partial class Form1 : Form
    {
        TcpClient client;
        StreamReader reader;
        StreamWriter writer;
        NetworkStream Stream;
        Thread receive;
        bool connect;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try{
                client = new TcpClient();
                client.Connect("localhost",5425);
                Stream = client.GetStream();
                connect = true;
                reader = new StreamReader(Stream);
                writer = new StreamWriter(Stream);
                receive = new Thread(new ThreadStart(Recieve));               
                receive.Start();             
            }
            catch(Exception ex){}
        }
                   
        private void Recieve(){
            try{
                while (connect)
                {
                    Thread.Sleep(1);
                    if (Stream.CanRead)
                    {
                        string temp = reader.ReadLine();
                        if (temp.Length > 0)
                            MessageBox.Show(temp);
                    }
                }
            }
            catch(Exception e){}
        }

        private void button2_Click(object sender, EventArgs e)
        {
            writer.WriteLine("search");
            writer.Flush();
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            connect = false;
            if (reader != null)
                reader.Close();
            if (writer != null)
                writer.Close();
            if (client != null)
                client.Close();
            if (receive != null)
                receive.Abort();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            writer.WriteLine("search1");
            writer.Flush();
        }                   
    }
}